Skip to content
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 @@ -547,6 +547,9 @@ Bug Fixes to Compiler Builtins
``void(char *, char *)`` to ``void(void *, void *)`` to match GCC's signature
for the same builtin. (#GH47833)

- ``__has_unique_object_representations(Incomplete[])`` is no longer accepted, per
`LWG4113 <https://cplusplus.github.io/LWG/issue4113>`_.

Bug Fixes to Attribute Support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed crash when a parameter to the ``clang::annotate`` attribute evaluates to ``void``. See #GH119125
Expand Down
14 changes: 9 additions & 5 deletions clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5418,6 +5418,15 @@ static bool CheckUnaryTypeTraitTypeCompleteness(Sema &S, TypeTrait UTT,
return !S.RequireCompleteType(
Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);

// has_unique_object_representations<T>
// remove_all_extents_t<T> shall be a complete type or cv void (LWG4113).
case UTT_HasUniqueObjectRepresentations:
ArgTy = QualType(ArgTy->getBaseElementTypeUnsafe(), 0);
if (ArgTy->isVoidType())
return true;
return !S.RequireCompleteType(
Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);

// C++1z [meta.unary.prop]:
// remove_all_extents_t<T> shall be a complete type or cv void.
case UTT_IsTrivial:
Expand Down Expand Up @@ -5445,13 +5454,8 @@ static bool CheckUnaryTypeTraitTypeCompleteness(Sema &S, TypeTrait UTT,
case UTT_HasTrivialCopy:
case UTT_HasTrivialDestructor:
case UTT_HasVirtualDestructor:
// has_unique_object_representations<T> when T is an array is defined in terms
// of has_unique_object_representations<remove_all_extents_t<T>>, so the base
// type needs to be complete even if the type is an incomplete array type.
case UTT_HasUniqueObjectRepresentations:
ArgTy = QualType(ArgTy->getBaseElementTypeUnsafe(), 0);
[[fallthrough]];

// C++1z [meta.unary.prop]:
// T shall be a complete type, cv void, or an array of unknown bound.
case UTT_IsDestructible:
Expand Down
10 changes: 10 additions & 0 deletions clang/test/SemaCXX/type-traits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3383,6 +3383,16 @@ static_assert(!__has_unique_object_representations(float), "definitely not Float
static_assert(!__has_unique_object_representations(double), "definitely not Floating Point");
static_assert(!__has_unique_object_representations(long double), "definitely not Floating Point");


static_assert(!__has_unique_object_representations(AnIncompleteType[]));
//expected-error@-1 {{incomplete type 'AnIncompleteType' used in type trait expression}}
static_assert(!__has_unique_object_representations(AnIncompleteType[][1]));
//expected-error@-1 {{incomplete type 'AnIncompleteType' used in type trait expression}}
static_assert(!__has_unique_object_representations(AnIncompleteType[1]));
//expected-error@-1 {{incomplete type 'AnIncompleteType' used in type trait expression}}
static_assert(!__has_unique_object_representations(AnIncompleteType));
//expected-error@-1 {{incomplete type 'AnIncompleteType' used in type trait expression}}

struct NoPadding {
int a;
int b;
Expand Down