re PR c++/52725 (error: "capture of non-variable" for new-expression incorrectly...
authorJason Merrill <jason@redhat.com>
Fri, 1 Jun 2012 21:19:22 +0000 (17:19 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 1 Jun 2012 21:19:22 +0000 (17:19 -0400)
PR c++/52725
* parser.c (cp_parser_binary_expression): Bail early if we're parsing
tentatively and the LHS has a parse error.

From-SVN: r188127

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

index 781f7501394be93fb9fce8dcf0048c3bc6bc07ad..ba5937acb4512527fab17fc80adb16017b439f76 100644 (file)
@@ -1,5 +1,9 @@
 2012-06-01  Jason Merrill  <jason@redhat.com>
 
+       PR c++/52725
+       * parser.c (cp_parser_binary_expression): Bail early if we're parsing
+       tentatively and the LHS has a parse error.
+
        PR c++/53137
        * pt.c (instantiate_class_template_1): Set LAMBDA_EXPR_THIS_CAPTURE.
        (instantiate_decl): Don't push_to_top_level for local class methods.
index 547f9e214388bfe375e1a58aefb9301b548d1825..7f9a94b5c061217989a730a1dece5edffb817a50 100644 (file)
@@ -7246,6 +7246,9 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p,
   current.lhs_type = ERROR_MARK;
   current.prec = prec;
 
+  if (cp_parser_error_occurred (parser))
+    return error_mark_node;
+
   for (;;)
     {
       /* Get an operator token.  */
index 76e4e6b0fe853fee7485f5079f7f004850495448..dd1c651a35727037782af3074e0cdeaf4f53eb89 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/52725
+       * g++.dg/parse/new6.C: New.
+       * g++.dg/template/sizeof-template-argument.C: Adjust error message.
+
 2012-06-01  Eric Botcazou  <ebotcazou@adacore.com>
 
        * c-c++-common/restrict-2.c: Revert previous change.
diff --git a/gcc/testsuite/g++.dg/parse/new6.C b/gcc/testsuite/g++.dg/parse/new6.C
new file mode 100644 (file)
index 0000000..213837c
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/52725
+
+struct A { };
+
+const int n = 42;
+
+void f()
+{
+  A** p = new (A*[n]);
+}
index 2cdc328598ea5b3187f63e63d628aba9ae4dd63d..31aeeec9bfcc827c2e8ecfadb6bdd074ce7f1fec 100644 (file)
@@ -3,9 +3,9 @@
 
 template<int> struct A {};
 
-template<typename> struct B : A <sizeof(=)> {}; /* { dg-error "parse error in template argument list" } */
+template<typename> struct B : A <sizeof(=)> {}; /* { dg-error "template argument" } */
 
-template<typename> struct C : A <sizeof(=)> {}; /* { dg-error "parse error in template argument list" } */
+template<typename> struct C : A <sizeof(=)> {}; /* { dg-error "template argument" } */
 
 int a;