]> granicus.if.org Git - clang/commitdiff
PR40674: fix assertion failure if a structured binding declaration has a
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 24 Aug 2019 01:23:57 +0000 (01:23 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 24 Aug 2019 01:23:57 +0000 (01:23 +0000)
tuple-like decomposition that produces value-dependent reference
bindings.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369829 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/CXX/dcl.decl/dcl.decomp/p3.cpp

index 0f260ab6e91c48cc860e189d39800b419b525bb4..633a1667b2dc9c89c324dd44cadebff59b5139bf 100644 (file)
@@ -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),
index 9b030c1a2e1385e3051e20a8addd40af7bb5808e..ce5eefc6bfdb416b8ad8d65879779fc51873d45b 100644 (file)
@@ -127,7 +127,7 @@ void referenced_type() {
   using ConstInt3 = decltype(bcr2);
 }
 
-struct C { template<int> int get(); };
+struct C { template<int> int get() const; };
 template<> struct std::tuple_size<C> { 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<const C *p> void dependent_binding_PR40674() {
+  const auto &[c] = *p;
+  (void)c;
+}
+
 struct D {
   // FIXME: Emit a note here explaining why this was ignored.
   template<int> struct get {};