diff options
author | Giovanni Bajo <giovannibajo@gcc.gnu.org> | 2004-02-19 03:06:09 +0000 |
---|---|---|
committer | Giovanni Bajo <giovannibajo@gcc.gnu.org> | 2004-02-19 03:06:09 +0000 |
commit | 063e900f40733fbc05ce229de4f1dbd6d5c14340 (patch) | |
tree | a8bd929a5fcc301ed9d55eda12db3cc738928639 | |
parent | d63d3c7c2ebeec64d40ad66b72cb761fd165072b (diff) | |
download | gcc-063e900f40733fbc05ce229de4f1dbd6d5c14340.zip gcc-063e900f40733fbc05ce229de4f1dbd6d5c14340.tar.gz gcc-063e900f40733fbc05ce229de4f1dbd6d5c14340.tar.bz2 |
re PR c++/14181 (Cryptic error message for code that compiled without warnings in 3.3.x)
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
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/parser.c | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4815fe6..e0cd765 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 7918602..3d6efe1 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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)) + {
+ error ("array bound forbidden after parenthesized type-id");
+ inform ("try removing the parentheses around the type-id");
+ cp_parser_direct_new_declarator (parser); + } } /* Otherwise, there must be a new-type-id. */ else |