diff options
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/explicit1.C | 11 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.pt/explicit71.C | 2 |
5 files changed, 32 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 62e395a..1cceeb8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-12-29 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + + PR c++/12403 + * parser.c (cp_parser_template_declaration_after_export): Set up + template specialization scope in case of explicit specialization. + 2003-12-28 Mark Mitchell <mark@codesourcery.com> PR c++/13081 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index eae46cf..46907ec 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -13961,19 +13961,23 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) if (!cp_parser_require (parser, CPP_LESS, "`<'")) return; - /* Parse the template parameters. */ - begin_template_parm_list (); /* If the next token is `>', then we have an invalid specialization. Rather than complain about an invalid template parameter, issue an error message here. */ if (cp_lexer_next_token_is (parser->lexer, CPP_GREATER)) { cp_parser_error (parser, "invalid explicit specialization"); + begin_specialization (); parameter_list = NULL_TREE; } else - parameter_list = cp_parser_template_parameter_list (parser); - parameter_list = end_template_parm_list (parameter_list); + { + /* Parse the template parameters. */ + begin_template_parm_list (); + parameter_list = cp_parser_template_parameter_list (parser); + parameter_list = end_template_parm_list (parameter_list); + } + /* Look for the `>'. */ cp_parser_skip_until_found (parser, CPP_GREATER, "`>'"); /* We just processed one more parameter list. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bfca531..14faa0d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2003-12-29 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + + PR c++/12403 + * g++.dg/parse/explicit1.C: New test. + * g++.old-deja/g++.pt/explicit71.C: Adjust expected error. + 2003-12-28 Mark Mitchell <mark@codesourcery.com> PR c++/13081 diff --git a/gcc/testsuite/g++.dg/parse/explicit1.C b/gcc/testsuite/g++.dg/parse/explicit1.C new file mode 100644 index 0000000..ced2adc --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/explicit1.C @@ -0,0 +1,11 @@ +// { dg-do compile } + +// Origin: stefaandr@hotmail.com + +// PR c++/12403: ICE when explicit specialization is not in +// namespace scope. + +struct foo { + template<typename T> void bar (T &t) {} + template<> void bar<double>(double &t) {} // { dg-error "explicit|non-namespace|member" } +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit71.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit71.C index 25ba9ff..03b8794 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/explicit71.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit71.C @@ -12,4 +12,4 @@ class bug { }; template <class X> template <> // { dg-error "" } invalid specialization -class bug<X>::a<char> {}; +class bug<X>::a<char> {}; // { dg-error "" } |