summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-09-26 19:09:09 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-09-26 19:09:09 +0000
commitd8d7a374377571f2f8bc091a4bdeb2ed80258360 (patch)
tree6c08cc12ebf14cf9cab26700bdf75dd817d7e480
parenta4fa0d8be759213520196b8477661173a71fdd1d (diff)
downloadbcm5719-llvm-d8d7a374377571f2f8bc091a4bdeb2ed80258360.tar.gz
bcm5719-llvm-d8d7a374377571f2f8bc091a4bdeb2ed80258360.zip
CheckStringInit has side effects; make sure we don't run it in VerifyOnly mode, at least for the moment. <rdar://problem/10185490>.
Sebastian, please take a look at this; I'm not entirely sure it is the right thing to do. llvm-svn: 140552
-rw-r--r--clang/lib/Sema/SemaInit.cpp8
-rw-r--r--clang/test/Sema/init.c4
2 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 9257b81335e..0c518c7bda1 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -744,8 +744,10 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity,
// type here, though.
if (Expr *Str = IsStringInit(expr, arrayType, SemaRef.Context)) {
- CheckStringInit(Str, ElemType, arrayType, SemaRef);
- UpdateStructuredListElement(StructuredList, StructuredIndex, Str);
+ if (!VerifyOnly) {
+ CheckStringInit(Str, ElemType, arrayType, SemaRef);
+ UpdateStructuredListElement(StructuredList, StructuredIndex, Str);
+ }
++Index;
return;
}
@@ -1116,13 +1118,13 @@ void InitListChecker::CheckArrayType(const InitializedEntity &Entity,
if (Index < IList->getNumInits()) {
if (Expr *Str = IsStringInit(IList->getInit(Index), arrayType,
SemaRef.Context)) {
- CheckStringInit(Str, DeclType, arrayType, SemaRef);
// We place the string literal directly into the resulting
// initializer list. This is the only place where the structure
// of the structured initializer list doesn't match exactly,
// because doing so would involve allocating one character
// constant for each string.
if (!VerifyOnly) {
+ CheckStringInit(Str, DeclType, arrayType, SemaRef);
UpdateStructuredListElement(StructuredList, StructuredIndex, Str);
StructuredList->resizeInits(SemaRef.Context, StructuredIndex);
}
diff --git a/clang/test/Sema/init.c b/clang/test/Sema/init.c
index f8110079d0e..2527e14fcbe 100644
--- a/clang/test/Sema/init.c
+++ b/clang/test/Sema/init.c
@@ -144,3 +144,7 @@ int PR4386_b = ((void *) PR4386_foo) != 0; // expected-error{{initializer elemen
int PR4386_c = ((void *) PR4386_zed) != 0;
int PR4386_zed() __attribute((weak));
+// <rdar://problem/10185490> (derived from SPEC vortex benchmark)
+typedef char strty[10];
+struct vortexstruct { strty s; };
+struct vortexstruct vortexvar = { "asdf" };
OpenPOWER on IntegriCloud