зеркало из https://github.com/microsoft/clang.git
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
This commit is contained in:
Родитель
08f7e6740c
Коммит
9046c224f1
|
@ -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)
|
||||
|
|
|
@ -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" };
|
||||
|
|
Загрузка…
Ссылка в новой задаче