Skip to content

Commit d7250a7

Browse files
committed
Add tests for cvref
1 parent 34d7408 commit d7250a7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,12 @@ std::optional<unsigned> Sema::GetDecompositionElementCount(QualType T,
16651665
SourceLocation Loc) {
16661666
const ASTContext &Ctx = getASTContext();
16671667
assert(!T->isDependentType());
1668+
1669+
Qualifiers Quals;
1670+
QualType Unqual = Context.getUnqualifiedArrayType(T, Quals);
1671+
Quals.removeCVRQualifiers();
1672+
T = Context.getQualifiedType(Unqual, Quals);
1673+
16681674
if (auto *CAT = Ctx.getAsConstantArrayType(T))
16691675
return CAT->getSize().getZExtValue();
16701676
if (auto *VT = T->getAs<VectorType>())

clang/test/SemaCXX/builtin-structured-binding-size.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ static_assert(__builtin_structured_binding_size(P1) == 0);
7474

7575

7676
static_assert(is_destructurable<S0>);
77+
static_assert(is_destructurable<const S0>);
78+
static_assert(is_destructurable<volatile S0>);
79+
static_assert(!is_destructurable<S0&>);
7780
static_assert(is_destructurable<S1>);
81+
static_assert(!is_destructurable<S1&>);
7882
static_assert(!is_destructurable<SE1>);
7983
static_assert(!is_destructurable<int>);
8084
static_assert(!is_destructurable<int[]>);
@@ -121,6 +125,12 @@ struct tuple_size<TSizeError> {
121125
};
122126

123127
static_assert(__builtin_structured_binding_size(T0) == 0);
128+
129+
static_assert(is_destructurable<const T0>);
130+
static_assert(is_destructurable<volatile T0>);
131+
static_assert(!is_destructurable<T0&>);
132+
133+
124134
static_assert(__builtin_structured_binding_size(T1) == 1);
125135
static_assert(__builtin_structured_binding_size(T42) == 42);
126136
static_assert(__builtin_structured_binding_size(TSizeError) == 42);

0 commit comments

Comments
 (0)