re PR c++/59682 (Invalid syntax accepted: new-placement without expression-list)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 16 Jun 2015 20:07:57 +0000 (20:07 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 16 Jun 2015 20:07:57 +0000 (20:07 +0000)
/cp
2015-06-16  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/59682
* parser.c (cp_parser_new_placement): Reject an empty expression-list.

/testsuite
2015-06-16  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/59682
* g++.dg/parse/new-placement1.C: New.

From-SVN: r224537

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/new-placement1.C [new file with mode: 0644]

index d2908c20a66c61e582656eae17867d04f859d2c0..88f33d7b84c8e7dd24546eccf15bfde2ac1d6b71 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-16  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/59682
+       * parser.c (cp_parser_new_placement): Reject an empty expression-list.
+
 2015-06-16  Jason Merrill  <jason@redhat.com>
 
        PR c++/66536
index 15b920a1fe93010c987e62a391cd5d0f655013e7..b8218714f6dddc2d1f28f70e33430d254001465f 100644 (file)
@@ -7560,6 +7560,9 @@ cp_parser_new_placement (cp_parser* parser)
                      /*allow_expansion_p=*/true,
                      /*non_constant_p=*/NULL));
 
+  if (expression_list && expression_list->is_empty ())
+    error ("expected expression-list or type-id");
+
   return expression_list;
 }
 
index 918cf5283c8b547f9cdfcd7bd626b7c487a6d63b..76870d374f61bb3e046e8661f70c249e7485870c 100644 (file)
@@ -1,3 +1,8 @@
+2015-06-16  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/59682
+       * g++.dg/parse/new-placement1.C: New.
+
 2015-06-16  David Malcolm  <dmalcolm@redhat.com>
 
        * jit.dg/all-non-failing-tests.h: Add test-compound-assignment.c.
diff --git a/gcc/testsuite/g++.dg/parse/new-placement1.C b/gcc/testsuite/g++.dg/parse/new-placement1.C
new file mode 100644 (file)
index 0000000..713690d
--- /dev/null
@@ -0,0 +1,3 @@
+// PR c++/59682
+
+int* p = new() int;  // { dg-error "expected expression-list or type-id" }