From f35de48c905803359f1a5454d6024806db8ca989 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 14 Jun 2011 06:38:10 +0000 Subject: 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 llvm-svn: 132983 --- clang/test/SemaCXX/c99-variable-length-array.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'clang/test/SemaCXX/c99-variable-length-array.cpp') diff --git a/clang/test/SemaCXX/c99-variable-length-array.cpp b/clang/test/SemaCXX/c99-variable-length-array.cpp index 98df1dbfe81..3f1d6a8a55c 100644 --- a/clang/test/SemaCXX/c99-variable-length-array.cpp +++ b/clang/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}; + } +} -- cgit v1.2.3