Skip to content
Closed
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
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ static IsTupleLike isTupleLike(Sema &S, SourceLocation Loc, QualType T,
return IsTupleLike::Error;

E = S.VerifyIntegerConstantExpression(E.get(), &Size, Diagnoser);
if (E.isInvalid())
if (E.isInvalid() || Size.isNegative())
return IsTupleLike::Error;

return IsTupleLike::TupleLike;
Expand Down
9 changes: 9 additions & 0 deletions clang/test/SemaCXX/builtin-structured-binding-size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,12 @@ static_assert(__is_same_as(tag_of_t<S1>, int));
static_assert(__is_same_as(tag_of_t<int>, int)); // error
// expected-error@-1 {{constraints not satisfied for alias template 'tag_of_t' [with T = int]}}
// expected-note@#tag-of-constr {{because substituted constraint expression is ill-formed: type 'int' cannot be decomposed}}

struct Neg {
int a;
};
template <> struct std::tuple_size<Neg> {
static constexpr int value = -1;
};

int e = __builtin_structured_binding_size(Neg); // expected-error {{type 'Neg' cannot be decomposed}}