Commit ca85f659 by Mark Mitchell Committed by Mark Mitchell

re PR c++/21369 (Template function definition rejected if function return type…

re PR c++/21369 (Template function definition rejected if function return type begins with 'struct')

	PR c++/21369
	* parser.c (cp_parser_elaborated_type_specifier): Don't treat
	class types as templates if the type is not appearing as part of a
	type definition or declaration.
	PR c++/21369
	* g++.dg/parse/ret-type3.C: New test.

From-SVN: r105241
parent 386cfa6f
2005-10-11 Mark Mitchell <mark@codesourcery.com>
PR c++/21369
* parser.c (cp_parser_elaborated_type_specifier): Don't treat
class types as templates if the type is not appearing as part of a
type definition or declaration.
2005-10-10 Mark Mitchell <mark@codesourcery.com> 2005-10-10 Mark Mitchell <mark@codesourcery.com>
PR c++/24277 PR c++/24277
......
...@@ -10066,6 +10066,8 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, ...@@ -10066,6 +10066,8 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
declaration context. */ declaration context. */
tag_scope ts; tag_scope ts;
bool template_p;
if (is_friend) if (is_friend)
/* Friends have special name lookup rules. */ /* Friends have special name lookup rules. */
ts = ts_within_enclosing_non_class; ts = ts_within_enclosing_non_class;
...@@ -10082,8 +10084,11 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, ...@@ -10082,8 +10084,11 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
warning (OPT_Wattributes, warning (OPT_Wattributes,
"type attributes are honored only at type definition"); "type attributes are honored only at type definition");
type = xref_tag (tag_type, identifier, ts, template_p =
parser->num_template_parameter_lists); (parser->num_template_parameter_lists
&& (cp_parser_next_token_starts_class_definition_p (parser)
|| cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON)));
type = xref_tag (tag_type, identifier, ts, template_p);
} }
} }
if (tag_type != enum_type) if (tag_type != enum_type)
......
2005-10-11 Mark Mitchell <mark@codesourcery.com>
PR c++/21369
* g++.dg/parse/ret-type3.C: New test.
2005-10-11 Andrew Pinski <pinskia@physics.uc.edu> 2005-10-11 Andrew Pinski <pinskia@physics.uc.edu>
PR tree-opt/23946 PR tree-opt/23946
// PR c++/21369
struct bar;
template <class T> struct bar *foo (T *p)
{
return p->t;
}
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