]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/14181 (Cryptic error message for code that compiled without warnings in...
authorGiovanni Bajo <giovannibajo@gcc.gnu.org>
Thu, 19 Feb 2004 03:06:09 +0000 (03:06 +0000)
committerGiovanni Bajo <giovannibajo@gcc.gnu.org>
Thu, 19 Feb 2004 03:06:09 +0000 (03:06 +0000)
PR c++/14181
* parser.c (cp_parser_new_expression): Parse an ill-formed
direct-new-declarator after a parenthesized type-id to emit good
diagnostic.

From-SVN: r78067

gcc/cp/ChangeLog
gcc/cp/parser.c

index 4815fe6a54e18136dec65b6aac3ffee090788b5f..e0cd7650aebee7eef8816fc40bd1d67f8e530aff 100644 (file)
@@ -1,3 +1,10 @@
+2004-02-19  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+       PR c++/14181
+       * parser.c (cp_parser_new_expression): Parse an ill-formed 
+       direct-new-declarator after a parenthesized type-id to emit good
+       diagnostic.
+
 2004-02-18  Kazu Hirata  <kazu@cs.umass.edu>
 
        * cp-tree.def, cvt.c: Update copyright.
index 7918602dee3de06ae0e0299f107f3849f56d36df..3d6efe1567914c5bf96004c04aad82a0abbbb1cf 100644 (file)
@@ -4531,6 +4531,15 @@ cp_parser_new_expression (cp_parser* parser)
       type = cp_parser_type_id (parser);
       /* Look for the closing `)'.  */
       cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
+      /* There should not be a direct-new-declarator in this production, 
+         but GCC used to allowed this, so we check and emit a sensible error
+        message for this case.  */
+      if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE))
+       {\r
+         error ("array bound forbidden after parenthesized type-id");\r
+         inform ("try removing the parentheses around the type-id");\r
+         cp_parser_direct_new_declarator (parser);
+       }
     }
   /* Otherwise, there must be a new-type-id.  */
   else