From: mmitchel Date: Tue, 11 Oct 2005 16:38:52 +0000 (+0000) Subject: PR c++/21369 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4f3113797abb30c984da55cc9c37a1deebe30f65;p=thirdparty%2Fgcc.git 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105241 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9fa7f0db3ca2..7842a019fe75 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2005-10-11 Mark Mitchell + + 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 PR c++/24277 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e5a03fcfe436..6d7d3c8cac6c 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -10066,6 +10066,8 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, declaration context. */ tag_scope ts; + bool template_p; + if (is_friend) /* Friends have special name lookup rules. */ ts = ts_within_enclosing_non_class; @@ -10082,8 +10084,11 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, warning (OPT_Wattributes, "type attributes are honored only at type definition"); - type = xref_tag (tag_type, identifier, ts, - parser->num_template_parameter_lists); + template_p = + (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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 96a21e9d9862..949c1da07ea5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-10-11 Mark Mitchell + + PR c++/21369 + * g++.dg/parse/ret-type3.C: New test. + 2005-10-11 Andrew Pinski PR tree-opt/23946 diff --git a/gcc/testsuite/g++.dg/parse/ret-type3.C b/gcc/testsuite/g++.dg/parse/ret-type3.C new file mode 100644 index 000000000000..33ee31748252 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/ret-type3.C @@ -0,0 +1,8 @@ +// PR c++/21369 + +struct bar; + +template struct bar *foo (T *p) +{ + return p->t; +}