[llvm-branch-commits] [cfe-branch] r293072 - Merging r292991:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jan 25 09:04:26 PST 2017


Author: hans
Date: Wed Jan 25 11:04:26 2017
New Revision: 293072

URL: http://llvm.org/viewvc/llvm-project?rev=293072&view=rev
Log:
Merging r292991:
------------------------------------------------------------------------
r292991 | rsmith | 2017-01-24 15:18:28 -0800 (Tue, 24 Jan 2017) | 3 lines

PR31742: Don't emit a bogus "zero size array" extwarn when initializing a
runtime-sized array from an empty list in an array new.

------------------------------------------------------------------------

Modified:
    cfe/branches/release_40/   (props changed)
    cfe/branches/release_40/lib/Sema/SemaInit.cpp
    cfe/branches/release_40/test/SemaCXX/new-delete-cxx0x.cpp

Propchange: cfe/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 25 11:04:26 2017
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:291850,291853,291865,291871,291877,291879,291881,291907,291955,291964,292032,292052,292183,292247,292265,292497,292555,292558-292559,292800,292847,292874
+/cfe/trunk:291850,291853,291865,291871,291877,291879,291881,291907,291955,291964,292032,292052,292183,292247,292265,292497,292555,292558-292559,292800,292847,292874,292991
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_40/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_40/lib/Sema/SemaInit.cpp?rev=293072&r1=293071&r2=293072&view=diff
==============================================================================
--- cfe/branches/release_40/lib/Sema/SemaInit.cpp (original)
+++ cfe/branches/release_40/lib/Sema/SemaInit.cpp Wed Jan 25 11:04:26 2017
@@ -1684,7 +1684,7 @@ void InitListChecker::CheckArrayType(con
     // If this is an incomplete array type, the actual type needs to
     // be calculated here.
     llvm::APSInt Zero(maxElements.getBitWidth(), maxElements.isUnsigned());
-    if (maxElements == Zero) {
+    if (maxElements == Zero && !Entity.isVariableLengthArrayNew()) {
       // Sizing an array implicitly to zero is not allowed by ISO C,
       // but is supported by GNU.
       SemaRef.Diag(IList->getLocStart(),

Modified: cfe/branches/release_40/test/SemaCXX/new-delete-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_40/test/SemaCXX/new-delete-cxx0x.cpp?rev=293072&r1=293071&r2=293072&view=diff
==============================================================================
--- cfe/branches/release_40/test/SemaCXX/new-delete-cxx0x.cpp (original)
+++ cfe/branches/release_40/test/SemaCXX/new-delete-cxx0x.cpp Wed Jan 25 11:04:26 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -triple=i686-pc-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -triple=i686-pc-linux-gnu -pedantic
 
 void ugly_news(int *ip) {
   (void)new int[-1]; // expected-error {{array size is negative}}
@@ -29,6 +29,7 @@ void fn(int n) {
   (void) new int[2] {1, 2};
   (void) new S[2] {1, 2};
   (void) new S[3] {1, 2};
+  (void) new S[n] {};
   // C++11 [expr.new]p19:
   //   If the new-expression creates an object or an array of objects of class
   //   type, access and ambiguity control are done for the allocation function,
@@ -44,6 +45,7 @@ void fn(int n) {
   (void) new T[2] {1, 2}; // ok
   (void) new T[3] {1, 2}; // expected-error {{no matching constructor}} expected-note {{in implicit initialization of array element 2}}
   (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}}
+  (void) new T[n] {}; // expected-error {{no matching constructor}} expected-note {{in implicit initialization of trailing array elements in runtime-sized array new}}
 }
 
 struct U {




More information about the llvm-branch-commits mailing list