]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/33124 (C++ frontend should not warn about new a[0] in template context)
authorPaolo Carlini <pcarlini@suse.de>
Sun, 16 Sep 2007 22:54:12 +0000 (22:54 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sun, 16 Sep 2007 22:54:12 +0000 (22:54 +0000)
/cp
2007-09-16  Paolo Carlini  <pcarlini@suse.de>

PR c++/33124
* init.c (build_new): Remove warning for zero-element
allocations.

/testsuite
2007-09-16  Paolo Carlini  <pcarlini@suse.de>

PR c++/33124
* g++.dg/warn/new1.C: Adjust.
* g++.dg/torture/str_empty.C: Likewise.

From-SVN: r128531

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/str_empty.C
gcc/testsuite/g++.dg/warn/new1.C

index 6e8a8b9e5b910836ad1571283ae65e432ff9f35a..aa4659f7654a0cd465006463aa4939d2dffc291d 100644 (file)
@@ -1,3 +1,9 @@
+2007-09-16  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/33124
+       * init.c (build_new): Remove warning for zero-element
+       allocations.
+
 2007-09-16  Nathan Sidwell  <nathan@codesourcery.com>
 
        cp/
index cafc721710701136bcfa8f821465dea925916555..e11d18433b3cd99c6a61c80b0d38d76ed5c93a43 100644 (file)
@@ -2173,21 +2173,6 @@ build_new (tree placement, tree type, tree nelts, tree init,
       if (!build_expr_type_conversion (WANT_INT | WANT_ENUM, nelts, false))
        pedwarn ("size in array new must have integral type");
       nelts = cp_save_expr (cp_convert (sizetype, nelts));
-      /* It is valid to allocate a zero-element array:
-
-          [expr.new]
-
-          When the value of the expression in a direct-new-declarator
-          is zero, the allocation function is called to allocate an
-          array with no elements.  The pointer returned by the
-          new-expression is non-null.  [Note: If the library allocation
-          function is called, the pointer returned is distinct from the
-          pointer to any other object.]
-
-        However, that is not generally useful, so we issue a
-        warning.  */
-      if (integer_zerop (nelts))
-       warning (0, "allocating zero-element array");
     }
 
   /* ``A reference cannot be created by the new operator.  A reference
index 1fea6a1daafd5db6660315a2a2c299d5235f3a2a..1c5209a66a576f291e95108117951bcc60aa55a2 100644 (file)
@@ -1,3 +1,9 @@
+2007-09-16  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/33124
+       * g++.dg/warn/new1.C: Adjust.
+       * g++.dg/torture/str_empty.C: Likewise.
+
 2007-09-16  Richard Sandiford  <rsandifo@nildram.co.uk>
 
        * gcc.target/mips/dse-1.c: New test.
index 0a6aabf7c333b57ab1b3a7227988db9040c5f8ae..e24f0b6ac9f73df4fdc7433666d4b8b0947472b2 100644 (file)
@@ -9,7 +9,7 @@ struct polynomial {
 
 void spline_rep1 ()
 {
-  new polynomial[0];  // { dg-warning "allocating zero-element array" }
+  new polynomial[0];  // { dg-bogus "allocating zero-element array" }
 }
 
 
index 6b78368aaecf68bc5e6b326081353fe4f4027f88..b50b2c354e7adbcecac15b7aa61f4a1cf6a62c28 100644 (file)
@@ -1,3 +1,3 @@
 void f() {
-  new int[0]; // { dg-warning "zero" }
+  new int[0]; // { dg-bogus "zero" }
 }
This page took 0.123336 seconds and 5 git commands to generate.