]> granicus.if.org Git - clang/commitdiff
Allow a string literal to initialize a tail array (PR8217), patch
authorChris Lattner <sabre@nondot.org>
Sun, 10 Oct 2010 17:49:49 +0000 (17:49 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 10 Oct 2010 17:49:49 +0000 (17:49 +0000)
by Pierre Habouzit!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116165 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaInit.cpp
test/CodeGen/init.c

index bac9f8fa7556a249af8ad582f1da25a7b2237928..7f0f2767c64143bc674f95327b86563e615bde93 100644 (file)
@@ -1474,7 +1474,8 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
         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)
index c8de99d901777c228c11411519d5bf82045cceda..dc9f82a6c1a679d39049d1a2875991c38212d6ac 100644 (file)
@@ -46,3 +46,15 @@ void f6() {
   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" };