[PATCH] Allow transformation of VariableArray to ConstantArray.
Serge Pavlov
sepavloff at gmail.com
Wed Feb 5 08:49:58 PST 2014
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>();
+ }
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2688.2.patch
Type: text/x-patch
Size: 1282 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140205/5ddca20c/attachment.bin>
More information about the cfe-commits
mailing list