Updated patch.
http://llvm-reviews.chandlerc.com/D2688
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2688?vs=6851&id=6893#toc
Files:
lib/Sema/TreeTransform.h
test/SemaCXX/c99-variable-length-array.cpp
Index: lib/Sema/TreeTransform.h
===================================================================
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -3929,7 +3929,9 @@
return QualType();
}
- VariableArrayTypeLoc NewTL = TLB.push<VariableArrayTypeLoc>(Result);
+ // We might have constant size array now, but fortunately it has the same
+ // location layout.
+ ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
NewTL.setLBracketLoc(TL.getLBracketLoc());
NewTL.setRBracketLoc(TL.getRBracketLoc());
NewTL.setSizeExpr(Size);
Index: test/SemaCXX/c99-variable-length-array.cpp
===================================================================
--- test/SemaCXX/c99-variable-length-array.cpp
+++ test/SemaCXX/c99-variable-length-array.cpp
@@ -140,3 +140,24 @@
}
int test = f<int>(0); // expected-note {{instantiation of}}
}
+
+namespace pr18633 {
+ struct A1 {
+ static const int sz;
+ static const int sz2;
+ };
+ const int A1::sz2 = 11;
+ template<typename T>
+ void func () {
+ int arr[A1::sz]; // expected-warning{{variable length arrays are a C99
feature}}
+ }
+ template<typename T>
+ void func2 () {
+ int arr[A1::sz2];
+ }
+ const int A1::sz = 12;
+ void func2() {
+ func<int>();
+ func2<int>();
+ }
+}
Index: lib/Sema/TreeTransform.h
===================================================================
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -3929,7 +3929,9 @@
return QualType();
}
- VariableArrayTypeLoc NewTL = TLB.push<VariableArrayTypeLoc>(Result);
+ // We might have constant size array now, but fortunately it has the same
+ // location layout.
+ ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
NewTL.setLBracketLoc(TL.getLBracketLoc());
NewTL.setRBracketLoc(TL.getRBracketLoc());
NewTL.setSizeExpr(Size);
Index: test/SemaCXX/c99-variable-length-array.cpp
===================================================================
--- test/SemaCXX/c99-variable-length-array.cpp
+++ test/SemaCXX/c99-variable-length-array.cpp
@@ -140,3 +140,24 @@
}
int test = f<int>(0); // expected-note {{instantiation of}}
}
+
+namespace pr18633 {
+ struct A1 {
+ static const int sz;
+ static const int sz2;
+ };
+ const int A1::sz2 = 11;
+ template<typename T>
+ void func () {
+ int arr[A1::sz]; // expected-warning{{variable length arrays are a C99 feature}}
+ }
+ template<typename T>
+ void func2 () {
+ int arr[A1::sz2];
+ }
+ const int A1::sz = 12;
+ void func2() {
+ func<int>();
+ func2<int>();
+ }
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits