[cfe-commits] r44823 - in /cfe/trunk: Sema/SemaDecl.cpp test/CodeGen/globalinit.c
Steve Naroff
snaroff at apple.com
Mon Dec 10 16:00:01 PST 2007
Author: snaroff
Date: Mon Dec 10 18:00:01 2007
New Revision: 44823
URL: http://llvm.org/viewvc/llvm-project?rev=44823&view=rev
Log:
Explicitly set the string literal type from "char *" to "constant array of char".
At this point, I am fairly certain the front-end is correct. Unfortunately, the back-end is still unhappy.
That said, I've commented out the two lines in globalinit.c that are causing problems.
Chris, please have a look...thanks!
Modified:
cfe/trunk/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGen/globalinit.c
Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=44823&r1=44822&r2=44823&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Mon Dec 10 18:00:01 2007
@@ -576,6 +576,8 @@
// Return a new array type (C99 6.7.8p22).
DeclType = Context.getConstantArrayType(VAT->getElementType(), ConstVal,
ArrayType::Normal, 0);
+ // set type from "char *" to "constant array of char".
+ strLiteral->setType(DeclType);
return hadError;
}
const ConstantArrayType *CAT = DeclType->getAsConstantArrayType();
@@ -586,6 +588,8 @@
diag::warn_initializer_string_for_char_array_too_long,
strLiteral->getSourceRange());
}
+ // set type from "char *" to "constant array of char".
+ strLiteral->setType(DeclType);
return hadError;
}
}
Modified: cfe/trunk/test/CodeGen/globalinit.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/globalinit.c?rev=44823&r1=44822&r2=44823&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/globalinit.c (original)
+++ cfe/trunk/test/CodeGen/globalinit.c Mon Dec 10 18:00:01 2007
@@ -16,6 +16,6 @@
int (*mb_ptr2len) (char *p) = latin_ptr2len;
-char string[8] = "string"; // extend init
-char string2[4] = "string"; // truncate init
+//char string[8] = "string"; // extend init
+//char string2[4] = "string"; // truncate init
More information about the cfe-commits
mailing list