Commit b298aa9b by Jason Merrill Committed by Jason Merrill

re PR c++/53563 (ICE in start_decl, at cp/decl.c:4427)

	PR c++/53563
	* parser.c (cp_parser_template_id): Add tag_type parm.
	(cp_parser_template_name): Likewise.
	(cp_parser_id_expression, cp_parser_unqualified_id): Adjust.
	(cp_parser_pseudo_destructor_name, cp_parser_type_name): Adjust.
	(cp_parser_simple_type_specifier, cp_parser_class_name): Adjust.
	(cp_parser_elaborated_type_specifier, cp_parser_class_head): Adjust.

From-SVN: r189024
parent a05deb55
2012-06-27 Jason Merrill <jason@redhat.com>
PR c++/53563
* parser.c (cp_parser_template_id): Add tag_type parm.
(cp_parser_template_name): Likewise.
(cp_parser_id_expression, cp_parser_unqualified_id): Adjust.
(cp_parser_pseudo_destructor_name, cp_parser_type_name): Adjust.
(cp_parser_simple_type_specifier, cp_parser_class_name): Adjust.
(cp_parser_elaborated_type_specifier, cp_parser_class_head): Adjust.
2012-06-27 Ramana Radhakrishnan <ramana.radhakrishnan@linaro.org> 2012-06-27 Ramana Radhakrishnan <ramana.radhakrishnan@linaro.org>
PR C++/51033 PR C++/51033
......
...@@ -2062,9 +2062,9 @@ static tree cp_parser_template_parameter ...@@ -2062,9 +2062,9 @@ static tree cp_parser_template_parameter
static tree cp_parser_type_parameter static tree cp_parser_type_parameter
(cp_parser *, bool *); (cp_parser *, bool *);
static tree cp_parser_template_id static tree cp_parser_template_id
(cp_parser *, bool, bool, bool); (cp_parser *, bool, bool, enum tag_types, bool);
static tree cp_parser_template_name static tree cp_parser_template_name
(cp_parser *, bool, bool, bool, bool *); (cp_parser *, bool, bool, bool, enum tag_types, bool *);
static tree cp_parser_template_argument_list static tree cp_parser_template_argument_list
(cp_parser *); (cp_parser *);
static tree cp_parser_template_argument static tree cp_parser_template_argument
...@@ -4466,6 +4466,7 @@ cp_parser_id_expression (cp_parser *parser, ...@@ -4466,6 +4466,7 @@ cp_parser_id_expression (cp_parser *parser,
id = cp_parser_template_id (parser, id = cp_parser_template_id (parser,
/*template_keyword_p=*/false, /*template_keyword_p=*/false,
/*check_dependency_p=*/true, /*check_dependency_p=*/true,
none_type,
declarator_p); declarator_p);
/* If that worked, we're done. */ /* If that worked, we're done. */
if (cp_parser_parse_definitely (parser)) if (cp_parser_parse_definitely (parser))
...@@ -4543,6 +4544,7 @@ cp_parser_unqualified_id (cp_parser* parser, ...@@ -4543,6 +4544,7 @@ cp_parser_unqualified_id (cp_parser* parser,
/* Try a template-id. */ /* Try a template-id. */
id = cp_parser_template_id (parser, template_keyword_p, id = cp_parser_template_id (parser, template_keyword_p,
check_dependency_p, check_dependency_p,
none_type,
declarator_p); declarator_p);
/* If it worked, we're done. */ /* If it worked, we're done. */
if (cp_parser_parse_definitely (parser)) if (cp_parser_parse_definitely (parser))
...@@ -4554,6 +4556,7 @@ cp_parser_unqualified_id (cp_parser* parser, ...@@ -4554,6 +4556,7 @@ cp_parser_unqualified_id (cp_parser* parser,
case CPP_TEMPLATE_ID: case CPP_TEMPLATE_ID:
return cp_parser_template_id (parser, template_keyword_p, return cp_parser_template_id (parser, template_keyword_p,
check_dependency_p, check_dependency_p,
none_type,
declarator_p); declarator_p);
case CPP_COMPL: case CPP_COMPL:
...@@ -4769,6 +4772,7 @@ cp_parser_unqualified_id (cp_parser* parser, ...@@ -4769,6 +4772,7 @@ cp_parser_unqualified_id (cp_parser* parser,
/* Try a template-id. */ /* Try a template-id. */
id = cp_parser_template_id (parser, template_keyword_p, id = cp_parser_template_id (parser, template_keyword_p,
/*check_dependency_p=*/true, /*check_dependency_p=*/true,
none_type,
declarator_p); declarator_p);
/* If that worked, we're done. */ /* If that worked, we're done. */
if (cp_parser_parse_definitely (parser)) if (cp_parser_parse_definitely (parser))
...@@ -6280,6 +6284,7 @@ cp_parser_pseudo_destructor_name (cp_parser* parser, ...@@ -6280,6 +6284,7 @@ cp_parser_pseudo_destructor_name (cp_parser* parser,
cp_parser_template_id (parser, cp_parser_template_id (parser,
/*template_keyword_p=*/true, /*template_keyword_p=*/true,
/*check_dependency_p=*/false, /*check_dependency_p=*/false,
class_type,
/*is_declaration=*/true); /*is_declaration=*/true);
/* Look for the `::' token. */ /* Look for the `::' token. */
cp_parser_require (parser, CPP_SCOPE, RT_SCOPE); cp_parser_require (parser, CPP_SCOPE, RT_SCOPE);
...@@ -12376,6 +12381,7 @@ static tree ...@@ -12376,6 +12381,7 @@ static tree
cp_parser_template_id (cp_parser *parser, cp_parser_template_id (cp_parser *parser,
bool template_keyword_p, bool template_keyword_p,
bool check_dependency_p, bool check_dependency_p,
enum tag_types tag_type,
bool is_declaration) bool is_declaration)
{ {
int i; int i;
...@@ -12432,6 +12438,7 @@ cp_parser_template_id (cp_parser *parser, ...@@ -12432,6 +12438,7 @@ cp_parser_template_id (cp_parser *parser,
templ = cp_parser_template_name (parser, template_keyword_p, templ = cp_parser_template_name (parser, template_keyword_p,
check_dependency_p, check_dependency_p,
is_declaration, is_declaration,
tag_type,
&is_identifier); &is_identifier);
if (templ == error_mark_node || is_identifier) if (templ == error_mark_node || is_identifier)
{ {
...@@ -12604,6 +12611,7 @@ cp_parser_template_name (cp_parser* parser, ...@@ -12604,6 +12611,7 @@ cp_parser_template_name (cp_parser* parser,
bool template_keyword_p, bool template_keyword_p,
bool check_dependency_p, bool check_dependency_p,
bool is_declaration, bool is_declaration,
enum tag_types tag_type,
bool *is_identifier) bool *is_identifier)
{ {
tree identifier; tree identifier;
...@@ -12710,7 +12718,7 @@ cp_parser_template_name (cp_parser* parser, ...@@ -12710,7 +12718,7 @@ cp_parser_template_name (cp_parser* parser,
/* Look up the name. */ /* Look up the name. */
decl = cp_parser_lookup_name (parser, identifier, decl = cp_parser_lookup_name (parser, identifier,
none_type, tag_type,
/*is_template=*/true, /*is_template=*/true,
/*is_namespace=*/false, /*is_namespace=*/false,
check_dependency_p, check_dependency_p,
...@@ -13699,6 +13707,7 @@ cp_parser_simple_type_specifier (cp_parser* parser, ...@@ -13699,6 +13707,7 @@ cp_parser_simple_type_specifier (cp_parser* parser,
type = cp_parser_template_id (parser, type = cp_parser_template_id (parser,
/*template_keyword_p=*/true, /*template_keyword_p=*/true,
/*check_dependency_p=*/true, /*check_dependency_p=*/true,
none_type,
/*is_declaration=*/false); /*is_declaration=*/false);
/* If the template-id did not name a type, we are out of /* If the template-id did not name a type, we are out of
luck. */ luck. */
...@@ -13811,6 +13820,7 @@ cp_parser_type_name (cp_parser* parser) ...@@ -13811,6 +13820,7 @@ cp_parser_type_name (cp_parser* parser)
type_decl = cp_parser_template_id (parser, type_decl = cp_parser_template_id (parser,
/*template_keyword_p=*/false, /*template_keyword_p=*/false,
/*check_dependency_p=*/false, /*check_dependency_p=*/false,
none_type,
/*is_declaration=*/false); /*is_declaration=*/false);
/* Note that this must be an instantiation of an alias template /* Note that this must be an instantiation of an alias template
because [temp.names]/6 says: because [temp.names]/6 says:
...@@ -14035,6 +14045,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, ...@@ -14035,6 +14045,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
decl = cp_parser_template_id (parser, template_p, decl = cp_parser_template_id (parser, template_p,
/*check_dependency_p=*/true, /*check_dependency_p=*/true,
tag_type,
is_declaration); is_declaration);
/* If we didn't find a template-id, look for an ordinary /* If we didn't find a template-id, look for an ordinary
identifier. */ identifier. */
...@@ -17865,6 +17876,7 @@ cp_parser_class_name (cp_parser *parser, ...@@ -17865,6 +17876,7 @@ cp_parser_class_name (cp_parser *parser,
/* Try a template-id. */ /* Try a template-id. */
decl = cp_parser_template_id (parser, template_keyword_p, decl = cp_parser_template_id (parser, template_keyword_p,
check_dependency_p, check_dependency_p,
tag_type,
is_declaration); is_declaration);
if (decl == error_mark_node) if (decl == error_mark_node)
return error_mark_node; return error_mark_node;
...@@ -18317,7 +18329,7 @@ cp_parser_class_head (cp_parser* parser, ...@@ -18317,7 +18329,7 @@ cp_parser_class_head (cp_parser* parser,
= cp_parser_nested_name_specifier_opt (parser, = cp_parser_nested_name_specifier_opt (parser,
/*typename_keyword_p=*/false, /*typename_keyword_p=*/false,
/*check_dependency_p=*/false, /*check_dependency_p=*/false,
/*type_p=*/false, /*type_p=*/true,
/*is_declaration=*/false); /*is_declaration=*/false);
/* If there was a nested-name-specifier, then there *must* be an /* If there was a nested-name-specifier, then there *must* be an
identifier. */ identifier. */
...@@ -18392,6 +18404,7 @@ cp_parser_class_head (cp_parser* parser, ...@@ -18392,6 +18404,7 @@ cp_parser_class_head (cp_parser* parser,
id = cp_parser_template_id (parser, id = cp_parser_template_id (parser,
/*template_keyword_p=*/false, /*template_keyword_p=*/false,
/*check_dependency_p=*/true, /*check_dependency_p=*/true,
class_key,
/*is_declaration=*/true); /*is_declaration=*/true);
/* If that didn't work, it could still be an identifier. */ /* If that didn't work, it could still be an identifier. */
if (!cp_parser_parse_definitely (parser)) if (!cp_parser_parse_definitely (parser))
......
2012-06-27 Jason Merrill <jason@redhat.com>
PR c++/53563
* g++.dg/parse/template27.C: New.
* g++.dg/template/crash74.C: Adjust expected output.
2012-06-27 Janus Weil <janus@gcc.gnu.org> 2012-06-27 Janus Weil <janus@gcc.gnu.org>
PR fortran/41951 PR fortran/41951
......
// PR c++/53563
template<class T>
struct s
{
template<class U>
s(){}
};
int main() {
struct s<void>::s<int> a; // { dg-error "no match" }
}
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
// { dg-do compile } // { dg-do compile }
// { dg-options "" } // { dg-options "" }
template<typename F> void foo () { } template<typename F> void foo () { } // { dg-prune-output "previous" }
template<typename F> struct foo<F> { }; // { dg-error "redeclared as" } template<typename F> struct foo<F> { }; // { dg-error "template" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment