]> granicus.if.org Git - clang/commitdiff
Sema: Dependent array designators cannot be checked
authorDavid Majnemer <david.majnemer@gmail.com>
Fri, 9 Jan 2015 01:39:09 +0000 (01:39 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Fri, 9 Jan 2015 01:39:09 +0000 (01:39 +0000)
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
test/SemaCXX/member-init.cpp

index 21e668f68ffd6c080f797104e972c8c1d3c21b21..db912d1d369a367cdea864ce84080956ad773249 100644 (file)
@@ -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()) {
index 5acb48010f04bd9e196408278d615ad4eeda4d99..b3ee30b456ec1f933c164cce1862e49e154d23af 100644 (file)
@@ -185,3 +185,10 @@ template<typename T> void f() {
 }
 void g() { f<int>(); } // expected-note {{in instantiation of function template specialization 'local_class::f<int>' requested here}}
 }
+
+namespace PR22056 {
+template <int N>
+struct S {
+  int x[3] = {[N] = 3};
+};
+}