r225494 - Sema: Dependent array designators cannot be checked
David Majnemer
david.majnemer at gmail.com
Thu Jan 8 17:39:10 PST 2015
Author: majnemer
Date: Thu Jan 8 19:39:09 2015
New Revision: 225494
URL: http://llvm.org/viewvc/llvm-project?rev=225494&view=rev
Log:
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.
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/SemaCXX/member-init.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=225494&r1=225493&r2=225494&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Jan 8 19:39:09 2015
@@ -3827,7 +3827,7 @@ DesignatedInitExpr::DesignatedInitExpr(c
// 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(c
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()) {
Modified: cfe/trunk/test/SemaCXX/member-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-init.cpp?rev=225494&r1=225493&r2=225494&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/member-init.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-init.cpp Thu Jan 8 19:39:09 2015
@@ -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};
+};
+}
More information about the cfe-commits
mailing list