PR c++/21369
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Oct 2005 16:38:52 +0000 (16:38 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Oct 2005 16:38:52 +0000 (16:38 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/ret-type3.C [new file with mode: 0644]

index 9fa7f0d..7842a01 100644 (file)
@@ -1,3 +1,10 @@
+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>
 
        PR c++/24277
index e5a03fc..6d7d3c8 100644 (file)
@@ -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)
index 96a21e9..949c1da 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        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 (file)
index 0000000..33ee317
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/21369
+
+struct bar;
+
+template <class T> struct bar *foo (T *p)
+{
+  return p->t;
+}