aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/c99-variable-length-array.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-06-14 06:38:10 +0000
committerChris Lattner <sabre@nondot.org>2011-06-14 06:38:10 +0000
commite1eed38733ed47d44f9d8c7731817c411eaf4141 (patch)
tree892eac9a394c9c6c0f3f8f4df555b7a855cab903 /test/SemaCXX/c99-variable-length-array.cpp
parent24c38e1ff057ce49c866294bf486444255e18f31 (diff)
when compiling in a GNU mode (e.g. gnu99) treat VLAs with a size that can be folded to a constant
as constant size arrays. This has slightly different semantics in some insane cases, but allows us to accept some constructs that GCC does. Continue to be pedantic in -std=c99 and other modes. This addressed rdar://8733881 - error "variable-sized object may not be initialized"; g++ accepts same code git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132983 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/c99-variable-length-array.cpp')
-rw-r--r--test/SemaCXX/c99-variable-length-array.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/SemaCXX/c99-variable-length-array.cpp b/test/SemaCXX/c99-variable-length-array.cpp
index 98df1dbfe8..3f1d6a8a55 100644
--- a/test/SemaCXX/c99-variable-length-array.cpp
+++ b/test/SemaCXX/c99-variable-length-array.cpp
@@ -121,3 +121,12 @@ namespace PR8209 {
(void)new vla_type; // expected-error{{variably}}
}
}
+
+namespace rdar8733881 { // rdar://8733881
+
+static const int k_cVal3 = (int)(1000*0.2f);
+ int f() {
+ // Ok, fold to a constant size array as an extension.
+ char rgch[k_cVal3] = {0};
+ }
+}