[cfe-commits] r148989 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaCXX/c99-variable-length-array.cpp
Eli Friedman
eli.friedman at gmail.com
Wed Jan 25 14:19:07 PST 2012
Author: efriedma
Date: Wed Jan 25 16:19:07 2012
New Revision: 148989
URL: http://llvm.org/viewvc/llvm-project?rev=148989&view=rev
Log:
Fix a crash involving a multi-dimensional dependent VLA. PR11744.
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=148989&r1=148988&r2=148989&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Wed Jan 25 16:19:07 2012
@@ -3593,8 +3593,12 @@
if (Result.isNull())
return QualType();
}
-
- ConstantArrayTypeLoc NewTL = TLB.push<ConstantArrayTypeLoc>(Result);
+
+ // We might have either a ConstantArrayType or a VariableArrayType now:
+ // a ConstantArrayType is allowed to have an element type which is a
+ // VariableArrayType if the type is dependent. Fortunately, all array
+ // types have the same location layout.
+ ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
NewTL.setLBracketLoc(TL.getLBracketLoc());
NewTL.setRBracketLoc(TL.getRBracketLoc());
Modified: cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp?rev=148989&r1=148988&r2=148989&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp (original)
+++ cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp Wed Jan 25 16:19:07 2012
@@ -130,3 +130,11 @@
char rgch[k_cVal3] = {0};
}
}
+
+namespace PR11744 {
+ template<typename T> int f(int n) {
+ T arr[3][n]; // expected-warning 3 {{variable length arrays are a C99 feature}}
+ return 3;
+ }
+ int test = f<int>(0); // expected-note {{instantiation of}}
+}
More information about the cfe-commits
mailing list