From: Chris Lattner Date: Sun, 10 Oct 2010 17:49:49 +0000 (+0000) Subject: Allow a string literal to initialize a tail array (PR8217), patch X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9046c224f16be3cef84f03b96a6c00a621c8383e;p=clang Allow a string literal to initialize a tail array (PR8217), patch by Pierre Habouzit! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116165 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index bac9f8fa75..7f0f2767c6 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -1474,7 +1474,8 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, Invalid = true; } - if (!hadError && !isa(DIE->getInit())) { + if (!hadError && !isa(DIE->getInit()) && + !isa(DIE->getInit())) { // The initializer is not an initializer list. SemaRef.Diag(DIE->getInit()->getSourceRange().getBegin(), diag::err_flexible_array_init_needs_braces) diff --git a/test/CodeGen/init.c b/test/CodeGen/init.c index c8de99d901..dc9f82a6c1 100644 --- a/test/CodeGen/init.c +++ b/test/CodeGen/init.c @@ -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" };