Skip to content

[Clang] Make passing incomplete types to builtin type-traits a non-sfinae-friendly error #121333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,9 @@ Bug Fixes to C++ Support
out of a module (which is the case e.g. in MSVC's implementation of ``std`` module). (#GH118218)
- Fixed a pack expansion issue in checking unexpanded parameter sizes. (#GH17042)
- Fixed a bug where captured structured bindings were modifiable inside non-mutable lambda (#GH95081)
- Passing incomplete types to ``__is_base_of`` and other builtin type traits for which the corresponding
standard type trait mandates a complete type is now a hard (non-sfinae-friendly) error
(`LWG3929 <https://wg21.link/LWG3929>`__.) (#GH121278)
- Clang now identifies unexpanded parameter packs within the type constraint on a non-type template parameter. (#GH88866)
- Fixed an issue while resolving type of expression indexing into a pack of values of non-dependent type (#GH121242)

Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -9361,7 +9361,7 @@ def note_inequality_comparison_to_or_assign : Note<
"use '|=' to turn this inequality comparison into an or-assignment">;

def err_incomplete_type_used_in_type_trait_expr : Error<
"incomplete type %0 used in type trait expression">;
"incomplete type %0 used in type trait expression">, NoSFINAE;

// C++20 constinit and require_constant_initialization attribute
def warn_cxx20_compat_constinit : Warning<
Expand Down
15 changes: 15 additions & 0 deletions clang/test/SemaCXX/type-traits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5031,3 +5031,18 @@ void remove_all_extents() {
using SomeArray = int[1][2];
static_assert(__is_same(remove_all_extents_t<const SomeArray>, const int));
}

namespace GH121278 {
// https://cplusplus.github.io/LWG/lwg-active.html#3929
#if __cplusplus >= 202002L
template <typename B, typename D>
concept C = __is_base_of(B, D);
// expected-error@-1 {{incomplete type 'GH121278::S' used in type trait expression}}
// expected-note@-2 {{while substituting template arguments into constraint expression here}}

struct T;
struct S;
bool b = C<T, S>;
// expected-note@-1 {{while checking the satisfaction of concept 'C<GH121278::T, GH121278::S>' requested here}}
#endif
}
Loading