r369829 - PR40674: fix assertion failure if a structured binding declaration has a
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 23 18:23:57 PDT 2019
Author: rsmith
Date: Fri Aug 23 18:23:57 2019
New Revision: 369829
URL: http://llvm.org/viewvc/llvm-project?rev=369829&view=rev
Log:
PR40674: fix assertion failure if a structured binding declaration has a
tuple-like decomposition that produces value-dependent reference
bindings.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p3.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=369829&r1=369828&r2=369829&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Aug 23 18:23:57 2019
@@ -1225,7 +1225,8 @@ static bool checkTupleLikeDecomposition(
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),
Modified: cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p3.cpp?rev=369829&r1=369828&r2=369829&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p3.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p3.cpp Fri Aug 23 18:23:57 2019
@@ -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 {};
More information about the cfe-commits
mailing list