[cfe-commits] r64155 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/Sema/designated-initializers.c

Douglas Gregor dgregor at apple.com
Mon Feb 9 11:45:19 PST 2009


Author: dgregor
Date: Mon Feb  9 13:45:19 2009
New Revision: 64155

URL: http://llvm.org/viewvc/llvm-project?rev=64155&view=rev
Log:
When handling "the rest" of a designated array subobject, maybe sure
to tell it that it wasn't (directly) designated. This way, we unwind
back to the explicit initializer list properly rather than getting
stuck in the wrong subobject. Fixes llvm.org/PR3519


Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp
    cfe/trunk/test/Sema/designated-initializers.c

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=64155&r1=64154&r2=64155&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Feb  9 13:45:19 2009
@@ -1197,7 +1197,7 @@
 
   // Check the remaining elements within this array subobject.
   bool prevHadError = hadError;
-  CheckArrayType(IList, CurrentObjectType, DesignatedStartIndex, true, Index,
+  CheckArrayType(IList, CurrentObjectType, DesignatedStartIndex, false, Index,
                  StructuredList, ElementIndex);
   return hadError && !prevHadError;  
 }

Modified: cfe/trunk/test/Sema/designated-initializers.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/designated-initializers.c?rev=64155&r1=64154&r2=64155&view=diff

==============================================================================
--- cfe/trunk/test/Sema/designated-initializers.c (original)
+++ cfe/trunk/test/Sema/designated-initializers.c Mon Feb  9 13:45:19 2009
@@ -151,3 +151,24 @@
   0, // expected-warning{{initializer overrides prior initialization of this subobject}}
   &xy[2].xx.a, &xy[2].xx, &global_float
 };
+
+// PR3519
+struct foo {
+  int arr[10];
+};
+
+struct foo Y[10] = {
+  [1] .arr [1] = 2,
+  [4] .arr [2] = 4
+};
+
+struct bar {
+  struct foo f;
+  float *arr[10];
+};
+
+extern float f;
+struct bar saloon = {
+  .f.arr[3] = 1,
+  .arr = { &f }
+};





More information about the cfe-commits mailing list