Author: cor3ntin Date: 2025-02-19T16:47:18+01:00 New Revision: 80ccf01c337f09146a2c502fe624f07c4b04b848
URL: https://github.com/llvm/llvm-project/commit/80ccf01c337f09146a2c502fe624f07c4b04b848 DIFF: https://github.com/llvm/llvm-project/commit/80ccf01c337f09146a2c502fe624f07c4b04b848.diff LOG: [Clang] Do not try to transform invalid bindings (#125658) In the presence of an invalid structured binding decomposition, some binding packs may be invalid and trying to transform them would produce a recovery expression that does not contains a pack, leading to assertions in places where we would expect a pack at that stage. Fixes #125165 Added: Modified: clang/lib/Sema/TreeTransform.h clang/test/SemaCXX/cxx2c-binding-pack.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 05cac8db3c42c..eaabfae2409f4 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -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; diff --git a/clang/test/SemaCXX/cxx2c-binding-pack.cpp b/clang/test/SemaCXX/cxx2c-binding-pack.cpp index 62e1da565f2b5..0f10dad3937ba 100644 --- a/clang/test/SemaCXX/cxx2c-binding-pack.cpp +++ b/clang/test/SemaCXX/cxx2c-binding-pack.cpp @@ -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}} +} + +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits