diff options
author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-03 02:48:44 +0000 |
---|---|---|
committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-03 02:48:44 +0000 |
commit | 2a03dcc3eff7c6fa1789a5724e35f471e0b13223 (patch) | |
tree | 9b03eb1ecacc97313559f4f706dc4a6cdffcee9a /gcc/cp | |
parent | 1740345a670ffc761f73b131d909abd87033abda (diff) | |
download | gcc-2a03dcc3eff7c6fa1789a5724e35f471e0b13223.tar.gz |
PR c++/18124
* parser.c (cp_parser_type_parameter): Robustify.
PR c++/18155
* parser.c (cp_parser_single_declaration): Disallow template
typedefs.
PR c++/18177
* typeck.c (build_const_cast): Use error_operand_p.
PR c++/18124
* g++.dg/template/crash25.C: New test.
PR c++/18155
* g++.dg/template/typedef2.C: New test.
* g++.dg/parse/crash13.C: Adjust error markers.
PR c++/18177
* g++.dg/conversion/const3.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@90016 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/cp/parser.c | 34 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 2 |
3 files changed, 38 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 61691e9d98c..ef855e337a8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2004-11-02 Mark Mitchell <mark@codesourcery.com> + + PR c++/18124 + * parser.c (cp_parser_type_parameter): Robustify. + + PR c++/18155 + * parser.c (cp_parser_single_declaration): Disallow template + typedefs. + + PR c++/18177 + * typeck.c (build_const_cast): Use error_operand_p. + 2004-11-02 Ziemowit Laski <zlaski@apple.com> * cp-lang.c (cxx_types_compatible_p): Remove prototype and definition. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e2afb3b192b..bea2f61ec3f 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8186,9 +8186,15 @@ cp_parser_type_parameter (cp_parser* parser) if (cp_lexer_next_token_is_not (parser->lexer, CPP_EQ) && cp_lexer_next_token_is_not (parser->lexer, CPP_GREATER) && cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA)) - identifier = cp_parser_identifier (parser); + { + identifier = cp_parser_identifier (parser); + /* Treat invalid names as if the parameter were nameless. */ + if (identifier == error_mark_node) + identifier = NULL_TREE; + } else identifier = NULL_TREE; + /* Create the template parameter. */ parameter = finish_template_template_parm (class_type_node, identifier); @@ -8231,15 +8237,13 @@ cp_parser_type_parameter (cp_parser* parser) /* Create the combined representation of the parameter and the default argument. */ - parameter = build_tree_list (default_argument, parameter); + parameter = build_tree_list (default_argument, parameter); } break; default: - /* Anything else is an error. */ - cp_parser_error (parser, - "expected %<class%>, %<typename%>, or %<template%>"); - parameter = error_mark_node; + gcc_unreachable (); + break; } return parameter; @@ -14801,6 +14805,11 @@ cp_parser_single_declaration (cp_parser* parser, cp_decl_specifier_seq decl_specifiers; bool function_definition_p = false; + /* This function is only used when processing a template + declaration. */ + gcc_assert (innermost_scope_kind () == sk_template_parms + || innermost_scope_kind () == sk_template_spec); + /* Defer access checks until we know what is being declared. */ push_deferring_access_checks (dk_deferred); @@ -14812,6 +14821,14 @@ cp_parser_single_declaration (cp_parser* parser, &declares_class_or_enum); if (friend_p) *friend_p = cp_parser_friend_p (&decl_specifiers); + + /* There are no template typedefs. */ + if (decl_specifiers.specs[(int) ds_typedef]) + { + error ("template declaration of %qs", "typedef"); + decl = error_mark_node; + } + /* Gather up the access checks that occurred the decl-specifier-seq. */ stop_deferring_access_checks (); @@ -14843,8 +14860,6 @@ cp_parser_single_declaration (cp_parser* parser, decl = error_mark_node; } } - else - decl = NULL_TREE; /* If it's not a template class, try for a template function. If the next token is a `;', then this declaration does not declare anything. But, if there were errors in the decl-specifiers, then @@ -14869,7 +14884,8 @@ cp_parser_single_declaration (cp_parser* parser, parser->object_scope = NULL_TREE; /* Look for a trailing `;' after the declaration. */ if (!function_definition_p - && !cp_parser_require (parser, CPP_SEMICOLON, "`;'")) + && (decl == error_mark_node + || !cp_parser_require (parser, CPP_SEMICOLON, "`;'"))) cp_parser_skip_to_end_of_block_or_statement (parser); return decl; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 3796acee56f..325dd5682f2 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5099,7 +5099,7 @@ build_const_cast_1 (tree dst_type, tree expr, bool complain, tree build_const_cast (tree type, tree expr) { - if (type == error_mark_node || expr == error_mark_node) + if (type == error_mark_node || error_operand_p (expr)) return error_mark_node; if (processing_template_decl) |