From 7a6182d48d63df5f2c8fbb112e0dc9c03c7e878a Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sat, 24 Aug 2019 01:23:57 +0000 Subject: [PATCH] PR40674: fix assertion failure if a structured binding declaration has a tuple-like decomposition that produces value-dependent reference bindings. llvm-svn: 369829 --- clang/lib/Sema/SemaDeclCXX.cpp | 3 ++- clang/test/CXX/dcl.decl/dcl.decomp/p3.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 0f260ab6e91c..633a1667b2dc 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -1225,7 +1225,8 @@ static bool checkTupleLikeDecomposition(Sema &S, if (E.isInvalid()) return true; RefVD->setInit(E.get()); - RefVD->checkInitIsICE(); + if (!E.get()->isValueDependent()) + RefVD->checkInitIsICE(); E = S.BuildDeclarationNameExpr(CXXScopeSpec(), DeclarationNameInfo(B->getDeclName(), Loc), diff --git a/clang/test/CXX/dcl.decl/dcl.decomp/p3.cpp b/clang/test/CXX/dcl.decl/dcl.decomp/p3.cpp index 9b030c1a2e13..ce5eefc6bfdb 100644 --- a/clang/test/CXX/dcl.decl/dcl.decomp/p3.cpp +++ b/clang/test/CXX/dcl.decl/dcl.decomp/p3.cpp @@ -127,7 +127,7 @@ void referenced_type() { using ConstInt3 = decltype(bcr2); } -struct C { template int get(); }; +struct C { template int get() const; }; template<> struct std::tuple_size { static const int value = 1; }; template<> struct std::tuple_element<0, C> { typedef int type; }; @@ -138,6 +138,12 @@ int member_get() { return c; } +constexpr C c = C(); +template void dependent_binding_PR40674() { + const auto &[c] = *p; + (void)c; +} + struct D { // FIXME: Emit a note here explaining why this was ignored. template struct get {};