From: Mark Mitchell Date: Mon, 5 Jan 2004 21:07:22 +0000 (+0000) Subject: re PR c++/12132 (spurious "int ._0" (or "int $_0) in error message) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=216bb6e1f75e2b77aed197ce0eddbe72d574047b;p=gcc.git re PR c++/12132 (spurious "int ._0" (or "int $_0) in error message) PR c++/12132 * parser.c (cp_parser_explicit_instantiation): Improve error recovery. (cp_parser_require): Improve indication of the error location. PR c++/12132 * g++.dg/template/error11.C: New test. From-SVN: r75441 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 79af88e2e98..3a6a6ae44b5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2004-01-05 Mark Mitchell + PR c++/12132 + * parser.c (cp_parser_explicit_instantiation): Improve error + recovery. + (cp_parser_require): Improve indication of the error location. + PR c++/13451 * parser.c (cp_parser_class_head): Reorder logic to check for invalid qualification. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 9a16f826d34..560ad486d1a 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8392,13 +8392,22 @@ cp_parser_explicit_instantiation (cp_parser* parser) /*parenthesized_p=*/NULL); cp_parser_check_for_definition_in_return_type (declarator, declares_class_or_enum); - decl = grokdeclarator (declarator, decl_specifiers, - NORMAL, 0, NULL); - /* Turn access control back on for names used during - template instantiation. */ - pop_deferring_access_checks (); - /* Do the explicit instantiation. */ - do_decl_instantiation (decl, extension_specifier); + if (declarator != error_mark_node) + { + decl = grokdeclarator (declarator, decl_specifiers, + NORMAL, 0, NULL); + /* Turn access control back on for names used during + template instantiation. */ + pop_deferring_access_checks (); + /* Do the explicit instantiation. */ + do_decl_instantiation (decl, extension_specifier); + } + else + { + pop_deferring_access_checks (); + /* Skip the body of the explicit instantiation. */ + cp_parser_skip_to_end_of_statement (parser); + } } /* We're done with the instantiation. */ end_explicit_instantiation (); @@ -14630,7 +14639,11 @@ cp_parser_require (cp_parser* parser, { /* Output the MESSAGE -- unless we're parsing tentatively. */ if (!cp_parser_simulate_error (parser)) - error ("expected %s", token_desc); + { + char *message = concat ("expected ", token_desc, NULL); + cp_parser_error (parser, message); + free (message); + } return NULL; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fc4e462beb3..dc661cf8062 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2004-01-05 Mark Mitchell + PR c++/12132 + * g++.dg/template/error11.C: New test. + PR c++/13451 * g++.dg/template/class2.C: New test. diff --git a/gcc/testsuite/g++.dg/template/error11.C b/gcc/testsuite/g++.dg/template/error11.C new file mode 100644 index 00000000000..3a469fd1a8c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/error11.C @@ -0,0 +1,4 @@ +// PR c++/12132 + +inline template void foo () {} // { dg-error "<" } +void abort (); // { dg-error ";" }