Allow a string literal to initialize a tail array (PR8217), patch

by Pierre Habouzit!

llvm-svn: 116165
This commit is contained in:
Chris Lattner 2010-10-10 17:49:49 +00:00
parent 52bea03e7a
commit 001b29ccc1
2 changed files with 14 additions and 1 deletions

View File

@ -1474,7 +1474,8 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
Invalid = true; 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. // The initializer is not an initializer list.
SemaRef.Diag(DIE->getInit()->getSourceRange().getBegin(), SemaRef.Diag(DIE->getInit()->getSourceRange().getBegin(),
diag::err_flexible_array_init_needs_braces) diag::err_flexible_array_init_needs_braces)

View File

@ -46,3 +46,15 @@ void f6() {
int x; int x;
long ids[] = { (long) &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" };