diff options
author | Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> | 2003-09-20 15:59:38 +0000 |
---|---|---|
committer | Kriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org> | 2003-09-20 15:59:38 +0000 |
commit | 4047b1642c8a8d6b9b918ac78e08bbb09856033d (patch) | |
tree | 4d8afe9a8f86b2c97d6a01dff49885940003206c | |
parent | 2f54a73fc1a1466dbe576bfe0aab80cea9d4ff93 (diff) | |
download | gcc-4047b1642c8a8d6b9b918ac78e08bbb09856033d.zip gcc-4047b1642c8a8d6b9b918ac78e08bbb09856033d.tar.gz gcc-4047b1642c8a8d6b9b918ac78e08bbb09856033d.tar.bz2 |
re PR c++/157 (Duplicate error message for invalid elaborated type specifier)
PR c++/157
* parser.c (cp_parser_direct_declarator): Clear
parser->num_template_parameter_lists when parsing function
parameters.
(cp_parser_constructor_declarator_p): Likewise.
* g++.dg/parse/crash12.C: New test.
From-SVN: r71605
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/parser.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/crash12.C | 24 |
4 files changed, 59 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a18706b..b7d65fe 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2003-09-20 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + + PR c++/157 + * parser.c (cp_parser_direct_declarator): Clear + parser->num_template_parameter_lists when parsing function + parameters. + (cp_parser_constructor_declarator_p): Likewise. + 2003-09-19 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> PR c++/495 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 73fc6c7..4114aea 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -9720,6 +9720,7 @@ cp_parser_direct_declarator (cp_parser* parser, if (!first || dcl_kind != CP_PARSER_DECLARATOR_NAMED) { tree params; + unsigned saved_num_template_parameter_lists; cp_parser_parse_tentatively (parser); @@ -9733,9 +9734,18 @@ cp_parser_direct_declarator (cp_parser* parser, parser->in_declarator_p = true; } + /* Inside the function parameter list, surrounding + template-parameter-lists do not apply. */ + saved_num_template_parameter_lists + = parser->num_template_parameter_lists; + parser->num_template_parameter_lists = 0; + /* Parse the parameter-declaration-clause. */ params = cp_parser_parameter_declaration_clause (parser); + parser->num_template_parameter_lists + = saved_num_template_parameter_lists; + /* If all went well, parse the cv-qualifier-seq and the exception-specification. */ if (cp_parser_parse_definitely (parser)) @@ -13436,6 +13446,7 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p) && !cp_parser_storage_class_specifier_opt (parser)) { tree type; + unsigned saved_num_template_parameter_lists; /* Names appearing in the type-specifier should be looked up in the scope of the class. */ @@ -13456,6 +13467,13 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p) } push_scope (type); } + + /* Inside the constructor parameter list, surrounding + template-parameter-lists do not apply. */ + saved_num_template_parameter_lists + = parser->num_template_parameter_lists; + parser->num_template_parameter_lists = 0; + /* Look for the type-specifier. */ cp_parser_type_specifier (parser, CP_PARSER_FLAGS_NONE, @@ -13463,6 +13481,10 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p) /*is_declarator=*/true, /*declares_class_or_enum=*/NULL, /*is_cv_qualifier=*/NULL); + + parser->num_template_parameter_lists + = saved_num_template_parameter_lists; + /* Leave the scope of the class. */ if (type) pop_scope (type); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fbf56c0..9e37289 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-09-20 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> + + PR c++/157 + * g++.dg/parse/crash12.C: New test. + 2003-09-19 Janis Johnson <janis187@us.ibm.com> * gcc.dg/compat/mixed-struct-check.h: New. diff --git a/gcc/testsuite/g++.dg/parse/crash12.C b/gcc/testsuite/g++.dg/parse/crash12.C new file mode 100644 index 0000000..cf947b2 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/crash12.C @@ -0,0 +1,24 @@ +// { dg-do compile } + +// Origin: Martin von Loewis <martin@v.loewis.de> + +// PR c++/157: Incorrect type/template decision in function parameter. + +template <class _Tp> class auto_ptr {}; +template <class _Tp> +class counted_ptr +{ +public: + counted_ptr(auto_ptr<_Tp>& __a); // { dg-error "candidate" } + auto_ptr<_Tp> auto_ptr(); +}; + +template <class _Tp> +inline counted_ptr<_Tp>::counted_ptr(class auto_ptr& __a) // { dg-error "required" } +{ // { dg-error "no type|not match|template" } +} + +template <class _Tp> +inline class auto_ptr<_Tp> counted_ptr<_Tp>::auto_ptr() +{ +} |