зеркало из https://github.com/microsoft/clang-1.git
Only emit string initializers in-place if types match. Fixes PR9373.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126883 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
75e85048e7
Коммит
0483a6fcf8
|
@ -562,7 +562,7 @@ public:
|
|||
|
||||
llvm::Constant *EmitArrayInitialization(InitListExpr *ILE) {
|
||||
unsigned NumInitElements = ILE->getNumInits();
|
||||
if (NumInitElements == 1 &&
|
||||
if (NumInitElements == 1 && ILE->getType() == ILE->getInit(0)->getType() &&
|
||||
(isa<StringLiteral>(ILE->getInit(0)) ||
|
||||
isa<ObjCEncodeExpr>(ILE->getInit(0))))
|
||||
return Visit(ILE->getInit(0));
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
|
||||
// Brace-enclosed string array initializers
|
||||
char a[] = { "asdf" };
|
||||
// CHECK: @a = global [5 x i8] c"asdf\00"
|
||||
|
||||
char a2[2][5] = { "asdf" };
|
||||
// CHECK: @a2 = global [2 x [5 x i8]] {{\[}}[5 x i8] c"asdf\00", [5 x i8] zeroinitializer]
|
||||
|
||||
// Double-implicit-conversions of array/functions (not legal C, but
|
||||
// clang accepts it for gcc compat).
|
||||
|
|
Загрузка…
Ссылка в новой задаче