]> granicus.if.org Git - clang/commitdiff
When handling "the rest" of a designated array subobject, maybe sure
authorDouglas Gregor <dgregor@apple.com>
Mon, 9 Feb 2009 19:45:19 +0000 (19:45 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 9 Feb 2009 19:45:19 +0000 (19:45 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64155 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaInit.cpp
test/Sema/designated-initializers.c

index 496dbcdefa480a03a357fffe0d7b45df36244d2c..27d8d5aa2e55499cd894a2ab56de5d4e58f9d334 100644 (file)
@@ -1197,7 +1197,7 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
 
   // 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;  
 }
index 53da306c4c320dec3b90d6d550e8d48a83368313..9c4429d02da34e66ae981a1604e29f8020462470 100644 (file)
@@ -151,3 +151,24 @@ struct XY { int before; struct XX xx, *xp; float* after; } xy[] = {
   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 }
+};