From fe587201feaebc69e6d18858bea85c77926b6ecf Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 15 Apr 2012 02:50:59 +0000 Subject: PR12226: don't generate wrong code if a braced string literal is used to initialize an array of unsigned char. Outside C++11 mode, this bug was benign, and just resulted in us emitting a constant which was double the required length, padded with 0s. In C++11, it resulted in us generating an array whose first element was something like i8 ptrtoint ([n x i8]* @str to i8). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154756 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprAgg.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'lib/CodeGen/CGExprAgg.cpp') diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index b6efc1cafa..975f572c0d 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -916,14 +916,8 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) { // Handle initialization of an array. if (E->getType()->isArrayType()) { - if (E->getNumInits() > 0) { - QualType T1 = E->getType(); - QualType T2 = E->getInit(0)->getType(); - if (CGF.getContext().hasSameUnqualifiedType(T1, T2)) { - EmitAggLoadOfLValue(E->getInit(0)); - return; - } - } + if (E->isStringLiteralInit()) + return Visit(E->getInit(0)); QualType elementType = CGF.getContext().getAsArrayType(E->getType())->getElementType(); -- cgit v1.2.3