[cfe-commits] r116165 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/CodeGen/init.c
Chris Lattner
sabre at nondot.org
Sun Oct 10 10:49:49 PDT 2010
Author: lattner
Date: Sun Oct 10 12:49:49 2010
New Revision: 116165
URL: http://llvm.org/viewvc/llvm-project?rev=116165&view=rev
Log:
Allow a string literal to initialize a tail array (PR8217), patch
by Pierre Habouzit!
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/CodeGen/init.c
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=116165&r1=116164&r2=116165&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Sun Oct 10 12:49:49 2010
@@ -1474,7 +1474,8 @@
Invalid = true;
}
- if (!hadError && !isa<InitListExpr>(DIE->getInit())) {
+ if (!hadError && !isa<InitListExpr>(DIE->getInit()) &&
+ !isa<StringLiteral>(DIE->getInit())) {
// The initializer is not an initializer list.
SemaRef.Diag(DIE->getInit()->getSourceRange().getBegin(),
diag::err_flexible_array_init_needs_braces)
Modified: cfe/trunk/test/CodeGen/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/init.c?rev=116165&r1=116164&r2=116165&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/init.c (original)
+++ cfe/trunk/test/CodeGen/init.c Sun Oct 10 12:49:49 2010
@@ -46,3 +46,15 @@
int x;
long ids[] = { (long) &x };
}
+
+
+
+
+// CHECK: @test7 = global{{.*}}{ i32 0, [4 x i8] c"bar\00" }
+// PR8217
+struct a7 {
+ int b;
+ char v[];
+};
+
+struct a7 test7 = { .b = 0, .v = "bar" };
More information about the cfe-commits
mailing list