]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/12132 (spurious "int ._0" (or "int $_0) in error message)
authorMark Mitchell <mark@codesourcery.com>
Mon, 5 Jan 2004 21:07:22 +0000 (21:07 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 5 Jan 2004 21:07:22 +0000 (21:07 +0000)
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

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/error11.C [new file with mode: 0644]

index 79af88e2e9826fba9a724d5fe64525f064951ae0..3a6a6ae44b58f5cc7afb04fac1e71ee7e5e94e3e 100644 (file)
@@ -1,5 +1,10 @@
 2004-01-05  Mark Mitchell  <mark@codesourcery.com>
 
+       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.
index 9a16f826d34668639e5d13931bc0a9261a685733..560ad486d1aa8a437c68fc50d6339e1974f1c219 100644 (file)
@@ -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;
     }
 }
index fc4e462beb357b1837ec32debe25555d52b6c6f9..dc661cf8062ca1356b19d26b560160715a246601 100644 (file)
@@ -1,5 +1,8 @@
 2004-01-05  Mark Mitchell  <mark@codesourcery.com>
 
+       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 (file)
index 0000000..3a469fd
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/12132
+
+inline template <int> void foo () {} // { dg-error "<" }
+void abort (); // { dg-error ";" }