forked from OSchip/llvm-project
Allow a string literal to initialize a tail array (PR8217), patch
by Pierre Habouzit! llvm-svn: 116165
This commit is contained in:
parent
52bea03e7a
commit
001b29ccc1
|
@ -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)
|
||||||
|
|
|
@ -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" };
|
||||||
|
|
Loading…
Reference in New Issue