aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@wasabisystems.com>2004-01-11 20:33:35 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2004-01-11 20:33:35 +0000
commite90c7b8433d23ac0d385e104d67f8a7c458dced0 (patch)
tree7162d93bf8ecdf6e43e1a396f1e68ea82f4cac8d /gcc
parentb4544c366abe2b38430cd70c0954ebeaaab8c401 (diff)
downloadgcc-e90c7b8433d23ac0d385e104d67f8a7c458dced0.zip
gcc-e90c7b8433d23ac0d385e104d67f8a7c458dced0.tar.gz
gcc-e90c7b8433d23ac0d385e104d67f8a7c458dced0.tar.bz2
re PR c++/3478 (Accepts invalid "enum typename")
PR c++/3478 * parser.c (cp_parser_decl_specifier_seq): If the first decl_spec is error_mark_node, don't add any more decl_specs. (cp_parser_init_declarator): After committing to a declaration, if the decl_specifiers start with error_mark_node, issue an error and change the type to "int". From-SVN: r75688
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/parser.c14
2 files changed, 22 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 24e088f..2d100c8 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2004-01-11 Ian Lance Taylor <ian@wasabisystems.com>
+
+ PR c++/3478
+ * parser.c (cp_parser_decl_specifier_seq): If the first decl_spec
+ is error_mark_node, don't add any more decl_specs.
+ (cp_parser_init_declarator): After committing to a declaration, if
+ the decl_specifiers start with error_mark_node, issue an error and
+ change the type to "int".
+
2004-01-09 Nathanael Nerode <neroden@gcc.gnu.org>
PR bootstrap/7817
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index a9e50ec..2f5c9d9 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -6717,7 +6717,8 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
}
/* Add the DECL_SPEC to the list of specifiers. */
- decl_specs = tree_cons (NULL_TREE, decl_spec, decl_specs);
+ if (decl_specs == NULL || TREE_VALUE (decl_specs) != error_mark_node)
+ decl_specs = tree_cons (NULL_TREE, decl_spec, decl_specs);
/* After we see one decl-specifier, further decl-specifiers are
always optional. */
@@ -9818,6 +9819,17 @@ cp_parser_init_declarator (cp_parser* parser,
possibly be looking at any other construct. */
cp_parser_commit_to_tentative_parse (parser);
+ /* If the decl specifiers were bad, issue an error now that we're
+ sure this was intended to be a declarator. Then continue
+ declaring the variable(s), as int, to try to cut down on further
+ errors. */
+ if (decl_specifiers != NULL
+ && TREE_VALUE (decl_specifiers) == error_mark_node)
+ {
+ cp_parser_error (parser, "invalid type in declaration");
+ TREE_VALUE (decl_specifiers) = integer_type_node;
+ }
+
/* Check to see whether or not this declaration is a friend. */
friend_p = cp_parser_friend_p (decl_specifiers);