<div dir="ltr">It seems to me the test have already been simplified enough, so I'm not quite sure what you are trying to do more than this. Isn't this just ready to submit?</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 12, 2017 at 5:46 PM, Yuka Takahashi via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">yamaguchi updated this revision to Diff 95064.<br>
yamaguchi added a comment.<br>
<br>
I've been trying to minimal the testcase, add comments to describe what it is testing, and fix styles of the testcase properly.<br>
However, I don't have clear idea what will be the best. I would like to ask for the advice.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D31591" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D31591</a><br>
<br>
Files:<br>
  lib/Sema/SemaInit.cpp<br>
  test/Sema/designated-<wbr>initializers.c<br>
<span class=""><br>
<br>
Index: lib/Sema/SemaInit.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- lib/Sema/SemaInit.cpp<br>
+++ lib/Sema/SemaInit.cpp<br>
@@ -2269,15 +2269,17 @@<br>
           assert(StructuredList-><wbr>getNumInits() == 1<br>
                  && "A union should never have more than one initializer!");<br>
<br>
-          // We're about to throw away an initializer, emit warning.<br>
-          SemaRef.Diag(D->getFieldLoc(),<br>
-                       diag::warn_initializer_<wbr>overrides)<br>
</span>-            << D->getSourceRange();<br>
<span class="">           Expr *ExistingInit = StructuredList->getInit(0);<br>
</span><span class="">-          SemaRef.Diag(ExistingInit-><wbr>getLocStart(),<br>
-                       diag::note_previous_<wbr>initializer)<br>
-            << /*FIXME:has side effects=*/0<br>
-            << ExistingInit->getSourceRange()<wbr>;<br>
+          if (ExistingInit) {<br>
+            // We're about to throw away an initializer, emit warning.<br>
+            SemaRef.Diag(D->getFieldLoc(),<br>
+                         diag::warn_initializer_<wbr>overrides)<br>
+              << D->getSourceRange();<br>
+            SemaRef.Diag(ExistingInit-><wbr>getLocStart(),<br>
+                         diag::note_previous_<wbr>initializer)<br>
+              << /*FIXME:has side effects=*/0<br>
</span>+              << ExistingInit->getSourceRange()<wbr>;<br>
<span class="">+          }<br>
<br>
           // remove existing initializer<br>
           StructuredList->resizeInits(<wbr>SemaRef.Context, 0);<br>
</span>Index: test/Sema/designated-<wbr>initializers.c<br>
==============================<wbr>==============================<wbr>=======<br>
--- test/Sema/designated-<wbr>initializers.c<br>
+++ test/Sema/designated-<wbr>initializers.c<br>
@@ -351,3 +351,20 @@<br>
   { { 'f', 'o', 'o' }, 1 },<br>
   [0].L[4] = 'x' // no-warning<br>
 };<br>
+<br>
+struct {<br>
+  struct { } s1;<br>
+  union {<br>
+    int a;<br>
+    int b;<br>
+  } u1;<br>
+} s = {<br>
+  .s1 = {<br>
+    .x = 0, // expected-error{{field designator}}<br>
+  },<br>
+<br>
+  .u1 = {<br>
+    .a = 0,<br>
+    .b = 0,<br>
+  },<br>
+};<br>
<br>
<br>
</blockquote></div><br></div>