aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2005-10-11 16:38:52 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2005-10-11 16:38:52 +0000
commitca85f659109df84a4119c39afc5231f1eedc1459 (patch)
tree023c7aeb69682b23b3d71f879065e214f8895f29
parent386cfa6f3f1aeba33362f4f3717c2df2980ade6c (diff)
downloadgcc-ca85f659109df84a4119c39afc5231f1eedc1459.zip
gcc-ca85f659109df84a4119c39afc5231f1eedc1459.tar.gz
gcc-ca85f659109df84a4119c39afc5231f1eedc1459.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/parser.c9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/ret-type3.C8
4 files changed, 27 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9fa7f0d..7842a01 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index e5a03fc..6d7d3c8 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 96a21e9..949c1da 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..33ee317
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/ret-type3.C
@@ -0,0 +1,8 @@
+// PR c++/21369
+
+struct bar;
+
+template <class T> struct bar *foo (T *p)
+{
+ return p->t;
+}