diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-10-10 17:49:49 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-10-10 17:49:49 +0000 |
| commit | 001b29ccc1ee5d0a884c90f30a9660f1f4b360cf (patch) | |
| tree | b2a32863180a087bbe01c2579370f6bbd88aa99e /clang | |
| parent | 52bea03e7a6f608d337f32f3c47b5d62f64204ad (diff) | |
| download | bcm5719-llvm-001b29ccc1ee5d0a884c90f30a9660f1f4b360cf.tar.gz bcm5719-llvm-001b29ccc1ee5d0a884c90f30a9660f1f4b360cf.zip | |
Allow a string literal to initialize a tail array (PR8217), patch
by Pierre Habouzit!
llvm-svn: 116165
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 3 | ||||
| -rw-r--r-- | clang/test/CodeGen/init.c | 12 |
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index bac9f8fa755..7f0f2767c64 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -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) diff --git a/clang/test/CodeGen/init.c b/clang/test/CodeGen/init.c index c8de99d9017..dc9f82a6c1a 100644 --- a/clang/test/CodeGen/init.c +++ b/clang/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" }; |

