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
2 changes: 1 addition & 1 deletion clang/lib/Sema/TreeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -12716,7 +12716,7 @@ TreeTransform<Derived>::TransformDeclRefExpr(DeclRefExpr *E) {
ValueDecl *ND
= cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
E->getDecl()));
if (!ND)
if (!ND || ND->isInvalidDecl())
return ExprError();

NamedDecl *Found = ND;
Expand Down
15 changes: 15 additions & 0 deletions clang/test/SemaCXX/cxx2c-binding-pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,18 @@ auto X = [] <typename = void> () {
static_assert(sizeof...(pack3) == 5);
};
} // namespace

namespace GH125165 {

template <typename = void>
auto f(auto t) {
const auto& [...pack] = t;
// expected-error@-1 {{cannot decompose non-class, non-array type 'char const'}}
(pack, ...);
};

void g() {
f('x'); // expected-note {{in instantiation}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, should this work: https://godbolt.org/z/dKcaa3jY4

We should also try other arguments types beside char like int, float etc

Copy link
Contributor

@ricejasonf ricejasonf Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That happens to work because the pack can be empty. In clang-19 it seems to still allow decomposition. https://godbolt.org/z/zMrqTYE8c

(I am not saying that it should though.... maybe because it is empty?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

}