From 18811908dc026d90a8a1f319f7c576b2e2ee3a2c Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Fri, 9 Jan 2015 01:39:09 +0000 Subject: [PATCH] Sema: Dependent array designators cannot be checked We forgot to mark designated initializer expression that contain type dependent array designators as type dependent. This would lead to crashes when we try to determine which array element we were trying to initialize. This fixes PR22056. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225494 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/Expr.cpp | 4 ++-- test/SemaCXX/member-init.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 21e668f68f..db912d1d36 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -3827,7 +3827,7 @@ DesignatedInitExpr::DesignatedInitExpr(const ASTContext &C, QualType Ty, // Compute type- and value-dependence. Expr *Index = IndexExprs[IndexIdx]; if (Index->isTypeDependent() || Index->isValueDependent()) - ExprBits.ValueDependent = true; + ExprBits.TypeDependent = ExprBits.ValueDependent = true; if (Index->isInstantiationDependent()) ExprBits.InstantiationDependent = true; // Propagate unexpanded parameter packs. @@ -3842,7 +3842,7 @@ DesignatedInitExpr::DesignatedInitExpr(const ASTContext &C, QualType Ty, Expr *End = IndexExprs[IndexIdx + 1]; if (Start->isTypeDependent() || Start->isValueDependent() || End->isTypeDependent() || End->isValueDependent()) { - ExprBits.ValueDependent = true; + ExprBits.TypeDependent = ExprBits.ValueDependent = true; ExprBits.InstantiationDependent = true; } else if (Start->isInstantiationDependent() || End->isInstantiationDependent()) { diff --git a/test/SemaCXX/member-init.cpp b/test/SemaCXX/member-init.cpp index 5acb48010f..b3ee30b456 100644 --- a/test/SemaCXX/member-init.cpp +++ b/test/SemaCXX/member-init.cpp @@ -185,3 +185,10 @@ template void f() { } void g() { f(); } // expected-note {{in instantiation of function template specialization 'local_class::f' requested here}} } + +namespace PR22056 { +template +struct S { + int x[3] = {[N] = 3}; +}; +} -- 2.40.0