<div dir="ltr">Hi Hans,<div><br></div><div>This is relatively minor, but it's safe and fixes a rejects-valid regression in some configurations. Might be worth taking for Clang 4.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 24 January 2017 at 15:18, Richard Smith via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Tue Jan 24 17:18:28 2017<br>
New Revision: 292991<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=292991&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=292991&view=rev</a><br>
Log:<br>
PR31742: Don't emit a bogus "zero size array" extwarn when initializing a<br>
runtime-sized array from an empty list in an array new.<br>
<br>
Modified:<br>
    cfe/trunk/lib/Sema/SemaInit.<wbr>cpp<br>
    cfe/trunk/test/SemaCXX/new-<wbr>delete-cxx0x.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaInit.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=292991&r1=292990&r2=292991&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Sema/<wbr>SemaInit.cpp?rev=292991&r1=<wbr>292990&r2=292991&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/SemaInit.<wbr>cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaInit.<wbr>cpp Tue Jan 24 17:18:28 2017<br>
@@ -1684,7 +1684,7 @@ void InitListChecker::<wbr>CheckArrayType(con<br>
     // If this is an incomplete array type, the actual type needs to<br>
     // be calculated here.<br>
     llvm::APSInt Zero(maxElements.getBitWidth()<wbr>, maxElements.isUnsigned());<br>
-    if (maxElements == Zero) {<br>
+    if (maxElements == Zero && !Entity.<wbr>isVariableLengthArrayNew()) {<br>
       // Sizing an array implicitly to zero is not allowed by ISO C,<br>
       // but is supported by GNU.<br>
       SemaRef.Diag(IList-><wbr>getLocStart(),<br>
<br>
Modified: cfe/trunk/test/SemaCXX/new-<wbr>delete-cxx0x.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/new-delete-cxx0x.cpp?rev=292991&r1=292990&r2=292991&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>SemaCXX/new-delete-cxx0x.cpp?<wbr>rev=292991&r1=292990&r2=<wbr>292991&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaCXX/new-<wbr>delete-cxx0x.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/new-<wbr>delete-cxx0x.cpp Tue Jan 24 17:18:28 2017<br>
@@ -1,4 +1,4 @@<br>
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -triple=i686-pc-linux-gnu<br>
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -triple=i686-pc-linux-gnu -pedantic<br>
<br>
 void ugly_news(int *ip) {<br>
   (void)new int[-1]; // expected-error {{array size is negative}}<br>
@@ -29,6 +29,7 @@ void fn(int n) {<br>
   (void) new int[2] {1, 2};<br>
   (void) new S[2] {1, 2};<br>
   (void) new S[3] {1, 2};<br>
+  (void) new S[n] {};<br>
   // C++11 [expr.new]p19:<br>
   //   If the new-expression creates an object or an array of objects of class<br>
   //   type, access and ambiguity control are done for the allocation function,<br>
@@ -44,6 +45,7 @@ void fn(int n) {<br>
   (void) new T[2] {1, 2}; // ok<br>
   (void) new T[3] {1, 2}; // expected-error {{no matching constructor}} expected-note {{in implicit initialization of array element 2}}<br>
   (void) new T[n] {1, 2}; // expected-error {{no matching constructor}} expected-note {{in implicit initialization of trailing array elements in runtime-sized array new}}<br>
+  (void) new T[n] {}; // expected-error {{no matching constructor}} expected-note {{in implicit initialization of trailing array elements in runtime-sized array new}}<br>
 }<br>
<br>
 struct U {<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>