[cfe-commits] r140552 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/Sema/init.c

Eli Friedman eli.friedman at gmail.com
Mon Sep 26 12:09:09 PDT 2011


Author: efriedma
Date: Mon Sep 26 14:09:09 2011
New Revision: 140552

URL: http://llvm.org/viewvc/llvm-project?rev=140552&view=rev
Log:
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.


Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/test/Sema/init.c

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=140552&r1=140551&r2=140552&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Sep 26 14:09:09 2011
@@ -744,8 +744,10 @@
     // 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 @@
   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);
       }

Modified: cfe/trunk/test/Sema/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/init.c?rev=140552&r1=140551&r2=140552&view=diff
==============================================================================
--- cfe/trunk/test/Sema/init.c (original)
+++ cfe/trunk/test/Sema/init.c Mon Sep 26 14:09:09 2011
@@ -144,3 +144,7 @@
 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" };





More information about the cfe-commits mailing list