This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: Faster cp_lexer_peek_token [revised]


This patch is a revised version of the one I posted this morning,
<http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02284.html>.  See that
message for discussion of the basic change and why it is a good idea.

The revisions correct all of the regressions in the test suite which I
observed via testing on powerpc-darwin.  I'm going to do overnight
testing on amd64-linux too.  Most of the regressions were due to error
messages moving, and in many cases I decided that the new locations
were better.  In particular, given a typical function definition

return_type function(argument list)
{
  body
}

if g++ found something objectionable about the head, the diagnostic
used to issue on the line of the opening brace; now it appears on the
line of the head itself.  I think this is better.  

Considering the very large number of affected messages (and
consequently of modified test cases) though, I am wondering if this
patch is appropriate for stage 3.  Comments would be appreciated.

Embedded in here is a tangential fix which causes g++ not to complain
about a declaration with no type when the type inbound to
grokdeclarator was error_mark_node, as this means some other
diagnostic has already been issued for that declaration.  I noticed
this as a wrongness because some of those messages moved, and I
discovered a couple of places in the testsuite where they were marked
as bogus.

zw

gcc/cp:
        * decl.c (grokfndecl): If ::main is found not to return int,
        correct it after issuing a diagnostic.
        (grokdeclarator): If the incoming type was error_mark_node, do
        not complain about declaring something with no type.
        (start_function): Change check for ::main not returning int to
        an assertion, as grokfndecl now catches this when the user did it.
        * init.c (perform_member_init, sort_mem_initializers)
        (emit_mem_initializers): Make most diagnostics be issued on
        the line of current_function_decl, not whatever the current
        input line is.
        * parser.c (cp_lexer_peek_token_emit_debug_info): Surround
        definition and declaration with #ifdef ENABLE_CHECKING.
        Avoid unnecessary use of fprintf.
        (cp_lexer_print_token, cp_lexer_debug_stream): Adjust stub
        definitions to avoid warnings.
        (cp_lexer_new_main): Add assertion that first token is not a
        padding token.
        (cp_lexer_new_from_token_array): Fold into ...
        (cp_lexer_new_from_tokens): ... here.  Add assertion that
        first token is not a padding token.
        (cp_lexer_set_source_position_from_token): Move nearer to callers.
        Remove unused lexer argument.
        (cp_lexer_peek_token): Just print debugging report (if enabled)
        and return lexer->next_token.
        (cp_lexer_skip_purged_tokens): Delete.
        (cp_lexer_next_token_is, cp_lexer_next_token_is_not): Make
        inline, simplify bodies.
        (cp_lexer_peek_nth_token): Add debugging report a la
        cp_lexer_peek_token.
        (cp_lexer_consume_token): Correct commentary.  Advance over
        purged tokens here.  Set current source position here, from
        token to be returned.  Avoid unnecessary use of fprintf.
        (cp_lexer_purge_token): Advance next_token pointer over this and
        subsequent purged tokens.
        (cp_parser_error): Adjust source position to that of the
        peeked token.
        (cp_parser_push_lexer_for_tokens, cp_parser_pop_lexer): New functions.
        (cp_parser_string_literal): Remove some excessive cleverness.
        (cp_parser_enum_specifier): Call start_enum before consuming
        the opening brace.
        (cp_parser_member_declaration): Make the "extra semicolon"
        diagnostic consistently-worded with the other place this is
        diagnosed.  Explicitly set the diagnostic location to the
        location of the offending semicolon.
        (cp_parser_enclosed_template_argument_list): Use %</%> quoting
        in diagnostics.  Do not use cp_parser_require.  Set location
        of diagnostics about improper use of '>>' to location of
        offending token.
        (cp_parser_late_parsing_for_member): Use cp_parser_push_lexer_for_tokens
        and cp_parser_pop_lexer.
        (cp_parser_late_parsing_default_args): Likewise.  Manually
        move some logic outside the loop.

gcc/testsuite:
        * g++.dg/ext/complit1.C
        * g++.dg/other/error2.C
        * g++.dg/other/nontype-1.C
        * g++.dg/parse/crash11.C
        * g++.dg/parse/crash12.C
        * g++.dg/parse/error15.C
        * g++.dg/parse/error4.C
        * g++.dg/parse/tmpl-outside1.C
        * g++.dg/parse/too-many-tmpl-args1.C
        * g++.dg/template/dependent-expr3.C
        * g++.dg/template/error10.C
        * g++.dg/template/instantiate1.C
        * g++.dg/template/vtable2.C
        * g++.dg/warn/Wshadow-1.C
        * g++.dg/warn/weak1.C
        * g++.old-deja/g++.brendan/crash16.C
        * g++.old-deja/g++.brendan/crash18.C
        * g++.old-deja/g++.brendan/crash48.C
        * g++.old-deja/g++.brendan/crash49.C
        * g++.old-deja/g++.brendan/crash55.C
        * g++.old-deja/g++.brendan/crash56.C
        * g++.old-deja/g++.brendan/crash8.C
        * g++.old-deja/g++.brendan/enum11.C
        * g++.old-deja/g++.brendan/enum8.C
        * g++.old-deja/g++.brendan/enum9.C
        * g++.old-deja/g++.brendan/friend3.C
        * g++.old-deja/g++.brendan/misc14.C
        * g++.old-deja/g++.bugs/900402_02.C
        * g++.old-deja/g++.bugs/900404_03.C
        * g++.old-deja/g++.bugs/900404_04.C
        * g++.old-deja/g++.bugs/900428_03.C
        * g++.old-deja/g++.jason/crash4.C
        * g++.old-deja/g++.jason/overload21.C
        * g++.old-deja/g++.jason/redecl1.C
        * g++.old-deja/g++.jason/report.C
        * g++.old-deja/g++.jason/rfg10.C
        * g++.old-deja/g++.jason/template30.C
        * g++.old-deja/g++.law/arm12.C
        * g++.old-deja/g++.law/ctors5.C
        * g++.old-deja/g++.law/cvt20.C
        * g++.old-deja/g++.law/init10.C
        * g++.old-deja/g++.law/init8.C
        * g++.old-deja/g++.law/visibility17.C
        * g++.old-deja/g++.law/visibility7.C
        * g++.old-deja/g++.mike/net8.C
        * g++.old-deja/g++.mike/p646.C
        * g++.old-deja/g++.mike/p700.C
        * g++.old-deja/g++.mike/p701.C
        * g++.old-deja/g++.mike/p811.C
        * g++.old-deja/g++.ns/template13.C
        * g++.old-deja/g++.other/array3.C
        * g++.old-deja/g++.other/crash25.C
        * g++.old-deja/g++.other/dtor3.C
        * g++.old-deja/g++.other/dtor4.C
        * g++.old-deja/g++.other/main1.C
        * g++.old-deja/g++.other/warn7.C
        * g++.old-deja/g++.pt/crash11.C
        * g++.old-deja/g++.pt/crash36.C
        * g++.old-deja/g++.pt/spec22.C
        * g++.old-deja/g++.pt/spec9.C
        * g++.old-deja/g++.pt/ttp52.C
        * g++.old-deja/g++.robertl/eb103.C
        * g++.old-deja/g++.robertl/eb121.C
        * g++.old-deja/g++.robertl/eb22.C
        * g++.old-deja/g++.robertl/eb8.C:
        Update locations and/or regexps of dg-error markers.
        Remove markers for some bogus messages that are no longer issued.

libstdc++-v3:
        * testsuite/20_util/memory/auto_ptr/assign_neg.cc
        * testsuite/23_containers/map/operators/1_neg.cc
        * testsuite/23_containers/set/operators/1_neg.cc:
        Update locations and/or regexps of dg-error markers.


===================================================================
Index: gcc/cp/decl.c
--- gcc/cp/decl.c	22 Sep 2004 10:55:20 -0000	1.1302
+++ gcc/cp/decl.c	23 Sep 2004 06:21:14 -0000
@@ -5588,7 +5588,10 @@ grokfndecl (tree ctype,
 	error ("cannot declare `::main' to be static");
       if (!same_type_p (TREE_TYPE (TREE_TYPE (decl)),
 			integer_type_node))
-	error ("`main' must return `int'");
+	{
+	  error ("`::main' must return `int'");
+	  TREE_TYPE (TREE_TYPE (decl)) = integer_type_node;
+	}
       inlinep = 0;
       publicp = 1;
     }
@@ -6457,6 +6460,7 @@ grokdeclarator (const cp_declarator *dec
   cp_decl_spec ds;
   cp_storage_class storage_class;
   bool unsigned_p, signed_p, short_p, long_p, thread_p;
+  bool type_was_error_mark_node = false;
 
   signed_p = declspecs->specs[(int)ds_signed];
   unsigned_p = declspecs->specs[(int)ds_unsigned];
@@ -6657,7 +6661,10 @@ grokdeclarator (const cp_declarator *dec
   /* Extract the basic type from the decl-specifier-seq.  */
   type = declspecs->type;
   if (type == error_mark_node)
-    type = NULL_TREE;
+    {
+      type = NULL_TREE;
+      type_was_error_mark_node = true;
+    }
   /* If the entire declaration is itself tagged as deprecated then
      suppress reports of deprecated items.  */
   if (type && TREE_DEPRECATED (type)
@@ -6748,7 +6755,9 @@ grokdeclarator (const cp_declarator *dec
 		 && in_namespace == NULL_TREE
 		 && current_namespace == global_namespace);
 
-      if (in_system_header || flag_ms_extensions)
+      if (type_was_error_mark_node)
+	/* We've already issued an error, don't complain more.  */;
+      else if (in_system_header || flag_ms_extensions)
 	/* Allow it, sigh.  */;
       else if (pedantic || ! is_main)
 	pedwarn ("ISO C++ forbids declaration of `%s' with no type",
@@ -10093,16 +10102,10 @@ start_function (cp_decl_specifier_seq *d
     maybe_apply_pragma_weak (decl1);
 
   if (DECL_MAIN_P (decl1))
-    {
-      /* If this doesn't return integer_type, or a typedef to
-	 integer_type, complain.  */
-      if (!same_type_p (TREE_TYPE (TREE_TYPE (decl1)), integer_type_node))
-	{
-	  if (pedantic || warn_return_type)
-	    pedwarn ("return type for `main' changed to `int'");
-	  TREE_TYPE (decl1) = default_function_type;
-	}
-    }
+    /* main must return int.  grokfndecl should have corrected it
+       (and issued a diagnostic) if the user got it wrong.  */
+    gcc_assert (same_type_p (TREE_TYPE (TREE_TYPE (decl1)),
+			     integer_type_node));
 
   start_preparsed_function (decl1, attrs, /*flags=*/SF_DEFAULT);
 
===================================================================
Index: gcc/cp/init.c
--- gcc/cp/init.c	21 Sep 2004 15:38:58 -0000	1.395
+++ gcc/cp/init.c	23 Sep 2004 06:21:14 -0000
@@ -315,9 +315,8 @@ perform_member_init (tree member, tree i
   /* Effective C++ rule 12 requires that all data members be
      initialized.  */
   if (warn_ecpp && !explicit && TREE_CODE (type) != ARRAY_TYPE)
-    warning ("`%D' should be initialized in the member initialization "
-	     "list", 
-	     member);
+    warning ("%J%qD should be initialized in the member initialization "
+	     "list", current_function_decl, member);
 
   if (init == void_type_node)
     init = NULL_TREE;
@@ -363,16 +362,17 @@ perform_member_init (tree member, tree i
 	    {
 	      init = build_default_init (type, /*nelts=*/NULL_TREE);
 	      if (TREE_CODE (type) == REFERENCE_TYPE)
-		warning
-		  ("default-initialization of `%#D', which has reference type",
-		   member);
+		warning ("%Jdefault-initialization of %q#D, "
+			 "which has reference type",
+			 current_function_decl, member);
 	    }
 	  /* member traversal: note it leaves init NULL */
 	  else if (TREE_CODE (type) == REFERENCE_TYPE)
-	    pedwarn ("uninitialized reference member `%D'", member);
+	    pedwarn ("%Juninitialized reference member %qD",
+		     current_function_decl, member);
 	  else if (CP_TYPE_CONST_P (type))
-	    pedwarn ("uninitialized member `%D' with `const' type `%T'",
-		     member, type);
+	    pedwarn ("%Juninitialized member %qD with %<const%> type %qT",
+		     current_function_decl, member, type);
 	}
       else if (TREE_CODE (init) == TREE_LIST)
 	/* There was an explicit member initialization.  Do some work
@@ -509,7 +509,8 @@ sort_mem_initializers (tree t, tree mem_
 	  break;
 
       /* Issue a warning if the explicit initializer order does not
-	 match that which will actually occur.  */
+	 match that which will actually occur.
+         ??? Are all these on the correct lines?  */
       if (warn_reorder && !subobject_init)
 	{
 	  if (TREE_CODE (TREE_PURPOSE (next_subobject)) == FIELD_DECL)
@@ -522,7 +523,7 @@ sort_mem_initializers (tree t, tree mem_
 	    cp_warning_at ("  `%#D'", subobject);
 	  else
 	    warning ("  base `%T'", subobject);
-	  warning ("  when initialized here");
+	  warning ("%J  when initialized here", current_function_decl);
 	}
 
       /* Look again, from the beginning of the list.  */
@@ -538,10 +539,11 @@ sort_mem_initializers (tree t, tree mem_
       if (TREE_VALUE (subobject_init))
 	{
 	  if (TREE_CODE (subobject) == FIELD_DECL)
-	    error ("multiple initializations given for `%D'", subobject);
+	    error ("%Jmultiple initializations given for %qD",
+		   current_function_decl, subobject);
 	  else
-	    error ("multiple initializations given for base `%T'", 
-		   subobject);
+	    error ("%Jmultiple initializations given for base %qT", 
+		   current_function_decl, subobject);
 	}
 
       /* Record the initialization.  */
@@ -607,8 +609,8 @@ sort_mem_initializers (tree t, tree mem_
 		  if (same_type_p (last_field_type, field_type))
 		    {
 		      if (TREE_CODE (field_type) == UNION_TYPE)
-			error ("initializations for multiple members of `%T'",
-				  last_field_type);
+			error ("%Jinitializations for multiple members of %qT",
+			       current_function_decl, last_field_type);
 		      done = 1;
 		      break;
 		    }
@@ -664,9 +666,9 @@ emit_mem_initializers (tree mem_inits)
       if (extra_warnings && !arguments 
 	  && DECL_COPY_CONSTRUCTOR_P (current_function_decl)
 	  && TYPE_NEEDS_CONSTRUCTING (BINFO_TYPE (subobject)))
-	warning ("base class `%#T' should be explicitly initialized in the "
+	warning ("%Jbase class `%#T' should be explicitly initialized in the "
 		 "copy constructor",
-		 BINFO_TYPE (subobject));
+		 current_function_decl, BINFO_TYPE (subobject));
 
       /* If an explicit -- but empty -- initializer list was present,
 	 treat it just like default initialization at this point.  */
===================================================================
Index: gcc/cp/parser.c
--- gcc/cp/parser.c	21 Sep 2004 20:46:57 -0000	1.251
+++ gcc/cp/parser.c	23 Sep 2004 06:21:14 -0000
@@ -113,8 +113,6 @@ typedef struct cp_token_cache GTY(())
 
 static cp_lexer *cp_lexer_new_main
   (void);
-static cp_lexer *cp_lexer_new_from_token_array
-  (cp_token *, cp_token *);
 static cp_lexer *cp_lexer_new_from_tokens
   (cp_token_cache *tokens);
 static void cp_lexer_destroy
@@ -133,10 +131,6 @@ static void cp_lexer_get_preprocessor_to
   (cp_lexer *, cp_token *);
 static inline cp_token *cp_lexer_peek_token
   (cp_lexer *);
-static void cp_lexer_peek_token_emit_debug_info
-  (cp_lexer *, cp_token *);
-static void cp_lexer_skip_purged_tokens
-  (cp_lexer *);
 static cp_token *cp_lexer_peek_nth_token
   (cp_lexer *, size_t);
 static inline bool cp_lexer_next_token_is
@@ -159,8 +153,6 @@ static void cp_lexer_commit_tokens
   (cp_lexer *);
 static void cp_lexer_rollback_tokens
   (cp_lexer *);
-static inline void cp_lexer_set_source_position_from_token
-  (cp_lexer *, const cp_token *);
 #ifdef ENABLE_CHECKING
 static void cp_lexer_print_token
   (FILE *, cp_token *);
@@ -170,10 +162,17 @@ static void cp_lexer_start_debugging
   (cp_lexer *) ATTRIBUTE_UNUSED;
 static void cp_lexer_stop_debugging
   (cp_lexer *) ATTRIBUTE_UNUSED;
+static void cp_lexer_peek_token_emit_debug_info
+  (cp_lexer *, cp_token *);
 #else
-#define cp_lexer_debug_stream NULL
-#define cp_lexer_print_token(str, tok)
+/* If we define cp_lexer_debug_stream to NULL it will provoke warnings
+   about passing NULL to functions that require non-NULL arguments
+   (fputs, fprintf).  It will never be used, so all we need is a value
+   of the right type that's guaranteed not to be NULL.  */
+#define cp_lexer_debug_stream stdout
+#define cp_lexer_print_token(str, tok) (void) 0
 #define cp_lexer_debugging_p(lexer) 0
+#define cp_lexer_peek_token_emit_debug_info(lexer, tok) (void) 0
 #endif /* ENABLE_CHECKING */
 
 static cp_token_cache *cp_token_cache_new
@@ -266,16 +265,18 @@ cp_lexer_new_main (void)
      string constant concatenation.  */
   c_lex_return_raw_strings = false;
 
+  gcc_assert (lexer->next_token->type != CPP_PURGED);
   return lexer;
 }
 
 /* Create a new lexer whose token stream is primed with the tokens in
-   the range [FIRST, LAST).  When these tokens are exhausted, no new
-   tokens will be read.  */
+   CACHE.  When these tokens are exhausted, no new tokens will be read.  */
 
 static cp_lexer *
-cp_lexer_new_from_token_array (cp_token *first, cp_token *last)
+cp_lexer_new_from_tokens (cp_token_cache *cache)
 {
+  cp_token *first = cache->first;
+  cp_token *last = cache->last;
   cp_lexer *lexer = GGC_CNEW (cp_lexer);
   cp_token *eof;
 
@@ -302,16 +303,9 @@ cp_lexer_new_from_token_array (cp_token 
   /* Initially we are not debugging.  */
   lexer->debugging_p = false;
 #endif
-  return lexer;
-}
 
-/* Create a new lexer whose token stream is primed with the tokens in
-   CACHE.  When these tokens are exhausted, no new tokens will be read.  */
-
-static cp_lexer *
-cp_lexer_new_from_tokens (cp_token_cache *cache)
-{
-  return cp_lexer_new_from_token_array (cache->first, cache->last);
+  gcc_assert (lexer->next_token->type != CPP_PURGED);
+  return lexer;
 }
 
 /* Frees all resources associated with LEXER. */
@@ -335,24 +329,6 @@ cp_lexer_debugging_p (cp_lexer *lexer)
 
 #endif /* ENABLE_CHECKING */
 
-/* Set the current source position from the information stored in
-   TOKEN.  */
-
-static inline void
-cp_lexer_set_source_position_from_token (cp_lexer *lexer ATTRIBUTE_UNUSED ,
-                                         const cp_token *token)
-{
-  /* Ideally, the source position information would not be a global
-     variable, but it is.  */
-
-  /* Update the line number and system header flag. */
-  if (token->type != CPP_EOF)
-    {
-      input_location = token->location;
-      in_system_header = token->in_system_header;
-    }
-}
-
 /* TOKEN points into the circular token buffer.  Return a pointer to
    the next token in the buffer.  */
 
@@ -484,28 +460,29 @@ cp_lexer_get_preprocessor_token (cp_lexe
     token->keyword = RID_MAX;
 }
 
+/* Update the globals input_location and in_system_header from TOKEN.   */
+static inline void
+cp_lexer_set_source_position_from_token (cp_token *token)
+{
+  if (token->type != CPP_EOF)
+    {
+      input_location = token->location;
+      in_system_header = token->in_system_header;
+    }
+}
+
 /* Return a pointer to the next token in the token stream, but do not
    consume it.  */
 
 static inline cp_token *
 cp_lexer_peek_token (cp_lexer *lexer)
 {
-  cp_token *token;
-
-  /* Skip over purged tokens if necessary. */
-  if (lexer->next_token->type == CPP_PURGED)
-    cp_lexer_skip_purged_tokens (lexer);
-
-  token = lexer->next_token;
-
-  /* Provide debugging output.  */
   if (cp_lexer_debugging_p (lexer))
-    cp_lexer_peek_token_emit_debug_info (lexer, token);
-
-  cp_lexer_set_source_position_from_token (lexer, token);
-  return token;
+    cp_lexer_peek_token_emit_debug_info (lexer, lexer->next_token);
+  return lexer->next_token;
 }
 
+#ifdef ENABLE_CHECKING
 /* Emit debug output for cp_lexer_peek_token.  Split out into a
    separate function so that cp_lexer_peek_token can be small and
    inlinable. */
@@ -514,35 +491,23 @@ static void
 cp_lexer_peek_token_emit_debug_info (cp_lexer *lexer ATTRIBUTE_UNUSED,
 				     cp_token *token ATTRIBUTE_UNUSED)
 {
-  fprintf (cp_lexer_debug_stream, "cp_lexer: peeking at token: ");
+  fputs ("cp_lexer: peeking at token: ", cp_lexer_debug_stream);
   cp_lexer_print_token (cp_lexer_debug_stream, token);
-  fprintf (cp_lexer_debug_stream, "\n");
-}
-
-/* Skip all tokens whose type is CPP_PURGED. */
-
-static void cp_lexer_skip_purged_tokens (cp_lexer *lexer)
-{
-  while (lexer->next_token->type == CPP_PURGED)
-    ++lexer->next_token;
+  putc ('\n', cp_lexer_debug_stream);
 }
+#endif
 
 /* Return true if the next token has the indicated TYPE.  */
 
-static bool
+static inline bool
 cp_lexer_next_token_is (cp_lexer* lexer, enum cpp_ttype type)
 {
-  cp_token *token;
-
-  /* Peek at the next token.  */
-  token = cp_lexer_peek_token (lexer);
-  /* Check to see if it has the indicated TYPE.  */
-  return token->type == type;
+  return cp_lexer_peek_token (lexer)->type == type;
 }
 
 /* Return true if the next token does not have the indicated TYPE.  */
 
-static bool
+static inline bool
 cp_lexer_next_token_is_not (cp_lexer* lexer, enum cpp_ttype type)
 {
   return !cp_lexer_next_token_is (lexer, type);
@@ -550,7 +515,7 @@ cp_lexer_next_token_is_not (cp_lexer* le
 
 /* Return true if the next token is the indicated KEYWORD.  */
 
-static bool
+static inline bool
 cp_lexer_next_token_is_keyword (cp_lexer* lexer, enum rid keyword)
 {
   cp_token *token;
@@ -562,7 +527,10 @@ cp_lexer_next_token_is_keyword (cp_lexer
 }
 
 /* Return a pointer to the Nth token in the token stream.  If N is 1,
-   then this is precisely equivalent to cp_lexer_peek_token.  */
+   then this is precisely equivalent to cp_lexer_peek_token (except
+   that it is not inline).  One would like to disallow that case, but
+   there is one case (cp_parser_nth_token_starts_template_id) where
+   the caller passes a variable for N and it might be 1.  */
 
 static cp_token *
 cp_lexer_peek_nth_token (cp_lexer* lexer, size_t n)
@@ -572,6 +540,10 @@ cp_lexer_peek_nth_token (cp_lexer* lexer
   /* N is 1-based, not zero-based.  */
   gcc_assert (n > 0);
 
+  if (cp_lexer_debugging_p (lexer))
+    fprintf (cp_lexer_debug_stream,
+	     "cp_lexer: peeking ahead %ld at token: ", (long)n);
+
   --n;
   token = lexer->next_token;
   while (n != 0)
@@ -581,39 +553,43 @@ cp_lexer_peek_nth_token (cp_lexer* lexer
 	--n;
     }
 
+  if (cp_lexer_debugging_p (lexer))
+    {
+      cp_lexer_print_token (cp_lexer_debug_stream, token);
+      putc ('\n', cp_lexer_debug_stream);
+    }
+
   return token;
 }
 
-/* Consume the next token.  The pointer returned is valid only until
-   another token is read.  Callers should preserve copy the token
-   explicitly if they will need its value for a longer period of
-   time.  */
+/* Return the next token, and advance the lexer's next_token pointer
+   to point to the next non-purged token.  */
 
 static cp_token *
 cp_lexer_consume_token (cp_lexer* lexer)
 {
-  cp_token *token;
+  cp_token *token = lexer->next_token;
 
-  /* Skip over purged tokens if necessary. */
-  if (lexer->next_token->type == CPP_PURGED)
-    cp_lexer_skip_purged_tokens (lexer);
+  do
+    ++lexer->next_token;
+  while (lexer->next_token->type == CPP_PURGED);
 
-  token = lexer->next_token++;
+  cp_lexer_set_source_position_from_token (token);
 
   /* Provide debugging output.  */
   if (cp_lexer_debugging_p (lexer))
     {
-      fprintf (cp_lexer_debug_stream, "cp_lexer: consuming token: ");
+      fputs ("cp_lexer: consuming token: ", cp_lexer_debug_stream);
       cp_lexer_print_token (cp_lexer_debug_stream, token);
-      fprintf (cp_lexer_debug_stream, "\n");
+      putc ('\n', cp_lexer_debug_stream);
     }
 
   return token;
 }
 
-/* Permanently remove the next token from the token stream.  There
-   must be a valid next token already; this token never reads
-   additional tokens from the preprocessor.  */
+/* Permanently remove the next token from the token stream, and
+   advance the next_token pointer to refer to the next non-purged
+   token.  */
 
 static void
 cp_lexer_purge_token (cp_lexer *lexer)
@@ -623,6 +599,10 @@ cp_lexer_purge_token (cp_lexer *lexer)
   tok->location = UNKNOWN_LOCATION;
   tok->value = NULL_TREE;
   tok->keyword = RID_MAX;
+
+  do
+    ++lexer->next_token;
+  while (lexer->next_token->type == CPP_PURGED);
 }
 
 /* Permanently remove all tokens after TOK, up to, but not
@@ -658,7 +638,6 @@ cp_lexer_handle_pragma (cp_lexer *lexer)
   s.len = TREE_STRING_LENGTH (token->value);
   s.text = (const unsigned char *) TREE_STRING_POINTER (token->value);
 
-  cp_lexer_set_source_position_from_token (lexer, token);
   cpp_handle_deferred_pragma (parse_in, &s);
 
   /* Clearing token->value here means that we will get an ICE if we
@@ -1788,16 +1767,21 @@ cp_parser_is_keyword (cp_token* token, e
   return token->keyword == keyword;
 }
 
-/* Issue the indicated error MESSAGE.  */
+/* If not parsing tentatively, issue a diagnostic of the form
+      FILE:LINE: MESSAGE before TOKEN
+   where TOKEN is the next token in the input stream.  MESSAGE
+   (specified by the caller) is usually of the form "expected
+   OTHER-TOKEN".  */
 
 static void
 cp_parser_error (cp_parser* parser, const char* message)
 {
-  /* Output the MESSAGE -- unless we're parsing tentatively.  */
   if (!cp_parser_simulate_error (parser))
     {
-      cp_token *token;
-      token = cp_lexer_peek_token (parser->lexer);
+      cp_token *token = cp_lexer_peek_token (parser->lexer);
+      /* This diagnostic makes more sense if it is tagged to the line
+	 of the token we just peeked at.  */
+      cp_lexer_set_source_position_from_token (token);
       c_parse_error (message,
 		     /* Because c_parser_error does not understand
 			CPP_KEYWORD, keywords are treated like
@@ -2399,6 +2383,36 @@ cp_parser_new (void)
   return parser;
 }
 
+/* Create a cp_lexer structure which will emit the tokens in CACHE
+   and push it onto the parser's lexer stack.  This is used for delayed
+   parsing of in-class method bodies and default arguments, and should
+   not be confused with tentative parsing.  */
+static void
+cp_parser_push_lexer_for_tokens (cp_parser *parser, cp_token_cache *cache)
+{
+  cp_lexer *lexer = cp_lexer_new_from_tokens (cache);
+  lexer->next = parser->lexer;
+  parser->lexer = lexer;
+
+  /* Move the current source position to that of the first token in the
+     new lexer.  */
+  cp_lexer_set_source_position_from_token (lexer->next_token);
+}
+
+/* Pop the top lexer off the parser stack.  This is never used for the
+   "main" lexer, only for those pushed by cp_parser_push_lexer_for_tokens.  */
+static void
+cp_parser_pop_lexer (cp_parser *parser)
+{
+  cp_lexer *lexer = parser->lexer;
+  parser->lexer = lexer->next;
+  cp_lexer_destroy (lexer);
+
+  /* Put the current source position back where it was before this
+     lexer was pushed.  */
+  cp_lexer_set_source_position_from_token (parser->lexer->next_token);
+}
+
 /* Lexical conventions [gram.lex]  */
 
 /* Parse an identifier.  Returns an IDENTIFIER_NODE representing the
@@ -2446,16 +2460,18 @@ cp_parser_string_literal (cp_parser *par
       return error_mark_node;
     }
 
-  /* Try to avoid the overhead of creating and destroying an obstac
+  /* Try to avoid the overhead of creating and destroying an obstack
      for the common case of just one string.  */
-  if (!cp_parser_is_string_literal (cp_lexer_peek_nth_token (parser->lexer, 2)))
+  if (!cp_parser_is_string_literal
+      (cp_lexer_peek_nth_token (parser->lexer, 2)))
     {
+      cp_lexer_consume_token (parser->lexer);
+
       str.text = (const unsigned char *)TREE_STRING_POINTER (tok->value);
       str.len = TREE_STRING_LENGTH (tok->value);
       count = 1;
       if (tok->type == CPP_WSTRING)
 	wide = true;
-      cp_lexer_consume_token (parser->lexer);
 
       strs = &str;
     }
@@ -2466,6 +2482,7 @@ cp_parser_string_literal (cp_parser *par
 
       do
 	{
+	  cp_lexer_consume_token (parser->lexer);
 	  count++;
 	  str.text = (unsigned char *)TREE_STRING_POINTER (tok->value);
 	  str.len = TREE_STRING_LENGTH (tok->value);
@@ -2474,11 +2491,7 @@ cp_parser_string_literal (cp_parser *par
 
 	  obstack_grow (&str_ob, &str, sizeof (cpp_string));
 
-	  /* We do it this way so that, if we have to issue semantic
-	     errors on this string literal, the source position will
-	     be that of the first token of the string.  */
-	  tok = cp_lexer_peek_nth_token (parser->lexer, 2);
-	  cp_lexer_consume_token (parser->lexer);
+	  tok = cp_lexer_peek_token (parser->lexer);
 	}
       while (cp_parser_is_string_literal (tok));
 
@@ -6641,9 +6654,9 @@ cp_parser_declaration_seq_opt (cp_parser
 	{
 	  /* A declaration consisting of a single semicolon is
 	     invalid.  Allow it unless we're being pedantic.  */
-	  if (pedantic && !in_system_header)
-	    pedwarn ("extra `;'");
 	  cp_lexer_consume_token (parser->lexer);
+	  if (pedantic && !in_system_header)
+	    pedwarn ("extra %<;%>");
 	  continue;
 	}
 
@@ -8371,7 +8384,7 @@ cp_parser_template_id (cp_parser *parser
   /* If we find the sequence `[:' after a template-name, it's probably
      a digraph-typo for `< ::'. Substitute the tokens and check if we can
      parse correctly the argument list.  */
-  next_token = cp_lexer_peek_nth_token (parser->lexer, 1);
+  next_token = cp_lexer_peek_token (parser->lexer);
   next_token_2 = cp_lexer_peek_nth_token (parser->lexer, 2);
   if (next_token->type == CPP_OPEN_SQUARE
       && next_token->flags & DIGRAPH
@@ -9835,14 +9848,17 @@ cp_parser_enum_specifier (cp_parser* par
   else
     identifier = make_anon_name ();
 
-  cp_lexer_consume_token (parser->lexer);
-
   /* Issue an error message if type-definitions are forbidden here.  */
   cp_parser_check_type_definition (parser);
 
-  /* Create the new type.  */
+  /* Create the new type.  We do this before consuming the opening brace
+     so the enum will be recorded as being on the line of its tag (or the
+     'enum' keyword, if there is no tag).  */
   type = start_enum (identifier);
 
+  /* Consume the opening brace.  */
+  cp_lexer_consume_token (parser->lexer);
+
   /* If the next token is not '}', then there are some enumerators.  */
   if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_BRACE))
     cp_parser_enumerator_list (parser, type);
@@ -12907,8 +12923,9 @@ cp_parser_member_declaration (cp_parser*
 	 name of the class.  */
       if (!decl_specifiers.any_specifiers_p)
 	{
-	  if (pedantic)
-	    pedwarn ("extra semicolon");
+	  cp_token *token = cp_lexer_peek_token (parser->lexer);
+	  if (pedantic && !token->in_system_header)
+	    pedwarn ("%Hextra %<;%>", &token->location);
 	}
       else
 	{
@@ -15079,25 +15096,37 @@ cp_parser_enclosed_template_argument_lis
     {
       if (!saved_greater_than_is_operator_p)
 	{
-	  /* If we're in a nested template argument list, the '>>' has to be
-	    a typo for '> >'. We emit the error message, but we continue
-	    parsing and we push a '>' as next token, so that the argument
-	    list will be parsed correctly..  */
-	  cp_token* token;
-	  error ("`>>' should be `> >' within a nested template argument list");
-	  token = cp_lexer_peek_token (parser->lexer);
+	  /* If we're in a nested template argument list, the '>>' has
+	    to be a typo for '> >'. We emit the error message, but we
+	    continue parsing and we push a '>' as next token, so that
+	    the argument list will be parsed correctly.  Note that the
+	    global source location is still on the token before the
+	    '>>', so we need to say explicitly where we want it.  */
+	  cp_token *token = cp_lexer_peek_token (parser->lexer);
+	  error ("%H%<>>%> should be %<> >%> "
+		 "within a nested template argument list",
+		 &token->location);
+
+	  /* ??? Proper recovery should terminate two levels of
+	     template argument list here.  */
 	  token->type = CPP_GREATER;
 	}
       else
 	{
-	  /* If this is not a nested template argument list, the '>>' is
-	    a typo for '>'. Emit an error message and continue.  */
-	  error ("spurious `>>', use `>' to terminate a template argument list");
+	  /* If this is not a nested template argument list, the '>>'
+	    is a typo for '>'. Emit an error message and continue.
+	    Same deal about the token location, but here we can get it
+	    right by consuming the '>>' before issuing the diagnostic.  */
 	  cp_lexer_consume_token (parser->lexer);
+	  error ("spurious %<>>%>, use %<>%> to terminate "
+		 "a template argument list");
 	}
     }
-  else if (!cp_parser_require (parser, CPP_GREATER, "`>'"))
-    error ("missing `>' to terminate the template argument list");
+  else if (!cp_lexer_next_token_is (parser->lexer, CPP_GREATER))
+    error ("missing %<>%> to terminate the template argument list");
+  else
+    /* It's what we want, a '>'; consume it.  */
+    cp_lexer_consume_token (parser->lexer);
   /* The `>' token might be a greater-than operator again now.  */
   parser->greater_than_is_operator_p
     = saved_greater_than_is_operator_p;
@@ -15116,8 +15145,6 @@ cp_parser_enclosed_template_argument_lis
 static void
 cp_parser_late_parsing_for_member (cp_parser* parser, tree member_function)
 {
-  cp_lexer *saved_lexer;
-
   /* If this member is a template, get the underlying
      FUNCTION_DECL.  */
   if (DECL_FUNCTION_TEMPLATE_P (member_function))
@@ -15154,15 +15181,8 @@ cp_parser_late_parsing_for_member (cp_pa
       if (function_scope)
 	push_function_context_to (function_scope);
 
-      /* Save away the current lexer.  */
-      saved_lexer = parser->lexer;
-      /* Make a new lexer to feed us the tokens saved for this function.  */
-      parser->lexer = cp_lexer_new_from_tokens (tokens);
-      parser->lexer->next = saved_lexer;
-
-      /* Set the current source position to be the location of the first
-	 token in the saved inline body.  */
-      cp_lexer_peek_token (parser->lexer);
+      /* Push the body of the function onto the lexer stack.  */
+      cp_parser_push_lexer_for_tokens (parser, tokens);
 
       /* Let the front end know that we going to be defining this
 	 function.  */
@@ -15176,8 +15196,7 @@ cp_parser_late_parsing_for_member (cp_pa
       /* Leave the scope of the containing function.  */
       if (function_scope)
 	pop_function_context_from (function_scope);
-      /* Restore the lexer.  */
-      parser->lexer = saved_lexer;
+      cp_parser_pop_lexer (parser);
     }
 
   /* Remove any template parameters from the symbol table.  */
@@ -15217,10 +15236,8 @@ cp_parser_save_default_args (cp_parser* 
 static void
 cp_parser_late_parsing_default_args (cp_parser *parser, tree fn)
 {
-  cp_lexer *saved_lexer;
-  cp_token_cache *tokens;
   bool saved_local_variables_forbidden_p;
-  tree parameters;
+  tree parm;
 
   /* While we're parsing the default args, we might (due to the
      statement expression extension) encounter more classes.  We want
@@ -15229,30 +15246,28 @@ cp_parser_late_parsing_default_args (cp_
   parser->unparsed_functions_queues
     = tree_cons (NULL_TREE, NULL_TREE, parser->unparsed_functions_queues);
 
-  for (parameters = TYPE_ARG_TYPES (TREE_TYPE (fn));
-       parameters;
-       parameters = TREE_CHAIN (parameters))
+  /* Local variable names (and the `this' keyword) may not appear
+     in a default argument.  */
+  saved_local_variables_forbidden_p = parser->local_variables_forbidden_p;
+  parser->local_variables_forbidden_p = true;
+
+  for (parm = TYPE_ARG_TYPES (TREE_TYPE (fn));
+       parm;
+       parm = TREE_CHAIN (parm))
     {
-      if (!TREE_PURPOSE (parameters)
-	  || TREE_CODE (TREE_PURPOSE (parameters)) != DEFAULT_ARG)
+      cp_token_cache *tokens;
+
+      if (!TREE_PURPOSE (parm)
+	  || TREE_CODE (TREE_PURPOSE (parm)) != DEFAULT_ARG)
 	continue;
 
-       /* Save away the current lexer.  */
-      saved_lexer = parser->lexer;
-       /* Create a new one, using the tokens we have saved.  */
-      tokens =  DEFARG_TOKENS (TREE_PURPOSE (parameters));
-      parser->lexer = cp_lexer_new_from_tokens (tokens);
-
-       /* Set the current source position to be the location of the
-     	  first token in the default argument.  */
-      cp_lexer_peek_token (parser->lexer);
-
-       /* Local variable names (and the `this' keyword) may not appear
-     	  in a default argument.  */
-      saved_local_variables_forbidden_p = parser->local_variables_forbidden_p;
-      parser->local_variables_forbidden_p = true;
-       /* Parse the assignment-expression.  */
-      TREE_PURPOSE (parameters) = cp_parser_assignment_expression (parser);
+       /* Push the saved tokens for the default argument onto the parser's
+	  lexer stack.  */
+      tokens = DEFARG_TOKENS (TREE_PURPOSE (parm));
+      cp_parser_push_lexer_for_tokens (parser, tokens);
+
+      /* Parse the assignment-expression.  */
+      TREE_PURPOSE (parm) = cp_parser_assignment_expression (parser);
 
       /* If the token stream has not been completely used up, then
 	 there was extra junk after the end of the default
@@ -15260,11 +15275,13 @@ cp_parser_late_parsing_default_args (cp_
       if (!cp_lexer_next_token_is (parser->lexer, CPP_EOF))
 	cp_parser_error (parser, "expected `,'");
 
-       /* Restore saved state.  */
-      parser->lexer = saved_lexer;
-      parser->local_variables_forbidden_p = saved_local_variables_forbidden_p;
+      /* Revert to the main lexer.  */
+      cp_parser_pop_lexer (parser);
     }
 
+  /* Restore the state of local_variables_forbidden_p.  */
+  parser->local_variables_forbidden_p = saved_local_variables_forbidden_p;
+
   /* Restore the queue.  */
   parser->unparsed_functions_queues
     = TREE_CHAIN (parser->unparsed_functions_queues);
===================================================================
Index: gcc/testsuite/g++.dg/ext/complit1.C
--- gcc/testsuite/g++.dg/ext/complit1.C	17 Oct 2003 04:56:47 -0000	1.2
+++ gcc/testsuite/g++.dg/ext/complit1.C	23 Sep 2004 06:21:15 -0000
@@ -11,6 +11,6 @@ public:
 };
 
 Foo::Foo(int v0, int v1)
-  : val_((int[]) {v0, v1})
-{				// { dg-error "" "" }
+  : val_((int[]) {v0, v1})  // { dg-error "" "" }
+{
 }
===================================================================
Index: gcc/testsuite/g++.dg/other/error2.C
--- gcc/testsuite/g++.dg/other/error2.C	15 Dec 2003 06:28:21 -0000	1.4
+++ gcc/testsuite/g++.dg/other/error2.C	23 Sep 2004 06:21:15 -0000
@@ -10,5 +10,5 @@ namespace N
   class B { friend void operator>>(int, class B); };
   class N { friend void operator>>(int,class N); };
 } 
-void N::operator>>(int, N::B)  // { dg-error "N::N::B" }
-{ } // { dg-error "" "" }
+void N::operator>>(int, N::B)  // { dg-error "N::N::B|N::operator>>" }
+{ }
===================================================================
Index: gcc/testsuite/g++.dg/other/nontype-1.C
--- gcc/testsuite/g++.dg/other/nontype-1.C	15 Feb 2004 15:00:54 -0000	1.1
+++ gcc/testsuite/g++.dg/other/nontype-1.C	23 Sep 2004 06:21:15 -0000
@@ -2,6 +2,6 @@ template <class Op>
 bool asfun(Op f,
            Op::first_argument_type a, // { dg-error "not a type" }
            Op::second_argument_type b) // { dg-error "not a type" }
-{                               // { dg-error "no type" }
+{
    return Op(a, b);
 }
===================================================================
Index: gcc/testsuite/g++.dg/parse/crash11.C
--- gcc/testsuite/g++.dg/parse/crash11.C	5 Feb 2004 16:50:57 -0000	1.3
+++ gcc/testsuite/g++.dg/parse/crash11.C	23 Sep 2004 06:21:15 -0000
@@ -19,8 +19,8 @@ struct B
   template <typename T>
   struct Template
   {
-    typedef typename A<A<TP>::Template>
-      ::template Template<T>::Type Type; // { dg-error "mismatch|class template|unqualified-id" }
+    typedef typename A<A<TP>::Template>  // { dg-error "mismatch|class template" }
+      ::template Template<T>::Type Type; // { dg-error "unqualified-id" }
   };
 };
 template <typename T>
===================================================================
Index: gcc/testsuite/g++.dg/parse/crash12.C
--- gcc/testsuite/g++.dg/parse/crash12.C	20 Sep 2003 15:59:38 -0000	1.1
+++ gcc/testsuite/g++.dg/parse/crash12.C	23 Sep 2004 06:21:15 -0000
@@ -14,8 +14,8 @@ public:
 };
 
 template <class _Tp>
-inline counted_ptr<_Tp>::counted_ptr(class auto_ptr& __a) // { dg-error "required" }
-{						// { dg-error "no type|not match|template" }
+inline counted_ptr<_Tp>::counted_ptr(class auto_ptr& __a) // { dg-error "required|not match|template" }
+{
 }
 
 template <class _Tp>
===================================================================
Index: gcc/testsuite/g++.dg/parse/error15.C
--- gcc/testsuite/g++.dg/parse/error15.C	5 Feb 2004 16:50:57 -0000	1.1
+++ gcc/testsuite/g++.dg/parse/error15.C	23 Sep 2004 06:21:15 -0000
@@ -35,5 +35,3 @@ struct C
 };
 
 // { dg-bogus "" "bogus excess errors in declaration" { xfail *-*-* } 16 }
-// { dg-bogus "" "bogus excess errors in declaration" { xfail *-*-* } 24 }
-// { dg-bogus "" "bogus excess errors in declaration" { xfail *-*-* } 34 }
===================================================================
Index: gcc/testsuite/g++.dg/parse/error4.C
--- gcc/testsuite/g++.dg/parse/error4.C	15 Dec 2003 06:28:22 -0000	1.1
+++ gcc/testsuite/g++.dg/parse/error4.C	23 Sep 2004 06:21:15 -0000
@@ -3,5 +3,5 @@
 struct X { 
   virtual void f(int, 
 		 itn,        // { dg-error "declared" }
-		 int);       // { dg-error "" }
+		 int);
 }; 
===================================================================
Index: gcc/testsuite/g++.dg/parse/tmpl-outside1.C
--- gcc/testsuite/g++.dg/parse/tmpl-outside1.C	22 Jan 2003 23:21:51 -0000	1.1
+++ gcc/testsuite/g++.dg/parse/tmpl-outside1.C	23 Sep 2004 06:21:15 -0000
@@ -8,3 +8,4 @@ struct X
 };
 
 typedef X::template Y<0> y; // { dg-error "template" }
+// { dg-bogus "with no type" "" { xfail *-*-* } 10 }
===================================================================
Index: gcc/testsuite/g++.dg/parse/too-many-tmpl-args1.C
--- gcc/testsuite/g++.dg/parse/too-many-tmpl-args1.C	6 Feb 2003 22:34:55 -0000	1.1
+++ gcc/testsuite/g++.dg/parse/too-many-tmpl-args1.C	23 Sep 2004 06:21:15 -0000
@@ -2,8 +2,8 @@
 // Origin: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
 // { dg-do compile }
 
-template <typename T> class A
-{                                                             // { dg-error "" }
+template <typename T> class A                                 // { dg-error "" }
+{
     struct B;
     template <typename U> friend typename A<U,void>::B foo(); // { dg-error "" }
 };
===================================================================
Index: gcc/testsuite/g++.dg/template/dependent-expr3.C
--- gcc/testsuite/g++.dg/template/dependent-expr3.C	15 Dec 2003 16:59:56 -0000	1.2
+++ gcc/testsuite/g++.dg/template/dependent-expr3.C	23 Sep 2004 06:21:15 -0000
@@ -10,5 +10,5 @@ template <typename K> struct Y : K {
 
 template <class T> struct Z {
   S< (bool)(&static_cast<Y<T> *>(0)->x == 0) > // { dg-error "" }
-  s; // { dg-error "" }
+  s;
 };
===================================================================
Index: gcc/testsuite/g++.dg/template/error10.C
--- gcc/testsuite/g++.dg/template/error10.C	18 Dec 2003 12:00:08 -0000	1.1
+++ gcc/testsuite/g++.dg/template/error10.C	23 Sep 2004 06:21:15 -0000
@@ -9,8 +9,8 @@
 template <class T>
 class A {};
 
-A<A<int>> blah;  // { dg-error "should be `> >' within" }
-A<int>> blah2; // { dg-error "spurious `>>'" }
+A<A<int>> blah;  // { dg-error "should be '> >' within" }
+A<int>> blah2; // { dg-error "spurious '>>'" }
 
 
 /*
@@ -66,5 +66,5 @@ struct K {};
 
 void KFunc(void);
 
-A<K<&KFunc>> k1;  // { dg-error "should be `> >' within" }
-K<&KFunc>> k2; // { dg-error "spurious `>>'" }
+A<K<&KFunc>> k1;  // { dg-error "should be '> >' within" }
+K<&KFunc>> k2; // { dg-error "spurious '>>'" }
===================================================================
Index: gcc/testsuite/g++.dg/template/instantiate1.C
--- gcc/testsuite/g++.dg/template/instantiate1.C	30 Oct 2002 15:54:09 -0000	1.3
+++ gcc/testsuite/g++.dg/template/instantiate1.C	23 Sep 2004 06:21:15 -0000
@@ -16,6 +16,6 @@ template <class T> struct Z {	// { dg-er
   Y<Z<T> > y;			// { dg-error "instantiated" }
 };
 
-struct ZZ : Z<int>
-{				// { dg-error "instantiated" }
+struct ZZ : Z<int>		// { dg-error "instantiated" }
+{
 };
===================================================================
Index: gcc/testsuite/g++.dg/template/vtable2.C
--- gcc/testsuite/g++.dg/template/vtable2.C	16 Aug 2004 14:29:27 -0000	1.1
+++ gcc/testsuite/g++.dg/template/vtable2.C	23 Sep 2004 06:21:15 -0000
@@ -11,8 +11,8 @@
 template <class T> struct inner {};
 
 template <class T> struct parent {
-  virtual void f()
-    { parent<inner<T> > p; };		// { dg-error "instantiation depth" }
+  virtual void f()			// { dg-error "instantiation depth" }
+    { parent<inner<T> > p; };
 };
 
 template struct parent<int>;
===================================================================
Index: gcc/testsuite/g++.dg/warn/Wshadow-1.C
--- gcc/testsuite/g++.dg/warn/Wshadow-1.C	20 May 2002 04:56:24 -0000	1.2
+++ gcc/testsuite/g++.dg/warn/Wshadow-1.C	23 Sep 2004 06:21:15 -0000
@@ -21,8 +21,8 @@ struct status			// { dg-bogus "shadowed 
 int decl1;			// { dg-warning "shadowed declaration" }
 int decl2;			// { dg-warning "shadowed declaration" }
 void foo (struct status &status,// { dg-bogus "shadows a global decl" }
-	  double decl1)
-{				// { dg-warning "shadows a global decl" }
+	  double decl1)		// { dg-warning "shadows a global decl" }
+{
 }
 
 void foo1 (int d)
===================================================================
Index: gcc/testsuite/g++.dg/warn/weak1.C
--- gcc/testsuite/g++.dg/warn/weak1.C	26 Apr 2003 21:31:23 -0000	1.4
+++ gcc/testsuite/g++.dg/warn/weak1.C	23 Sep 2004 06:21:15 -0000
@@ -1,6 +1,5 @@
 // { dg-do run }
-// { dg-do compile { target *-*-coff i?86-pc-cygwin } }
-// { dg-warning "weak declaration" "COFF format does not support weak" { target *-*-coff i?86-pc-cygwin powerpc-ibm-aix4* rs6000-ibm-aix4* } 5 }
+// { dg-require-weak "" }
 
 extern void foo (void) __attribute__ ((weak));
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.brendan/crash16.C
--- gcc/testsuite/g++.old-deja/g++.brendan/crash16.C	1 May 2003 02:02:34 -0000	1.4
+++ gcc/testsuite/g++.old-deja/g++.brendan/crash16.C	23 Sep 2004 06:21:15 -0000
@@ -1,12 +1,12 @@
-// { dg-do assemble { xfail *-*-* } }
+// { dg-do compile }
 // GROUPS passed old-abort
 class Graph {
 public:
       unsigned         char N;
-      Graph(void) {}; // { dg-error "" } previously defined here
+      Graph(void) {}; // { dg-error "previously defined here" }
 }
 
-Graph::Graph(void)
-{    N = 10;// { dg-error "" }  return type.*
+Graph::Graph(void)    // { dg-error "return type|redefinition" }
+{    N = 10;
 }
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.brendan/crash18.C
--- gcc/testsuite/g++.old-deja/g++.brendan/crash18.C	1 May 2003 02:02:34 -0000	1.4
+++ gcc/testsuite/g++.old-deja/g++.brendan/crash18.C	23 Sep 2004 06:21:15 -0000
@@ -1,4 +1,4 @@
-// { dg-do assemble  }
+// { dg-do compile }
 // GROUPS passed old-abort
 typedef int element;
 class Pix {
@@ -7,11 +7,12 @@ public:
     Pix(const Pix&);
 
     // Friend functions so that v == x works as does x == v works
-    friend int operator==(void *v, const Pix& x)
-        { return v == index; }// { dg-error "" } .*
-    friend int operator==(void *v, const Pix& x)
-        { return v != index; }// { dg-error "" } .*
+    friend int operator==(void *v, const Pix& x) // { dg-error "previously" }
+    { return v == index; }  // { dg-error "from this location" }
+    // ??? should be operator!=
+    friend int operator==(void *v, const Pix& x) // { dg-error "redefinition" }
+    { return v != index; }
 private:
 //    friend class List<T>;
-    element *index; // { dg-error "" } invalid use of member
+    element *index; // { dg-error "invalid use of non-static data member" }
 };
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.brendan/crash48.C
--- gcc/testsuite/g++.old-deja/g++.brendan/crash48.C	1 May 2003 02:02:34 -0000	1.5
+++ gcc/testsuite/g++.old-deja/g++.brendan/crash48.C	23 Sep 2004 06:21:15 -0000
@@ -1,22 +1,22 @@
-// { dg-do assemble  }
+// { dg-do compile }
 // GROUPS passed old-abort
-class internal { // { dg-error "" } candidates are
+class internal { // { dg-error "internal::internal" }
 	int field;
 	int anotherfield;
 };
 
-class bug { // { dg-error "" } several errors
+class bug { // { dg-error "bug::bug" }
 	internal* numbers;
 	bug(int size);
 };
 
-bug::bug(int size)
-{ // { dg-error "" } candidates
-	numbers = new internal(size * size);// { dg-error "" }  no match.*
+bug::bug(int size) // { dg-error "bug::bug" }
+{
+  numbers = new internal(size * size);// { dg-error "no match" }
 }
 
 int
 main()
 {
-	bug test;// { dg-error "" }  no match
+  bug test; // { dg-error "no match" }
 }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.brendan/crash49.C
--- gcc/testsuite/g++.old-deja/g++.brendan/crash49.C	1 May 2003 02:02:34 -0000	1.5
+++ gcc/testsuite/g++.old-deja/g++.brendan/crash49.C	23 Sep 2004 06:21:15 -0000
@@ -5,8 +5,8 @@
 const int keys = 10;
 const int key[keys] = {6, key[1], 2, keys, 1, 7, 6, key[2], key[8]};
 
-void main()
-{ // { dg-error "" } return type for main
+void main()  // { dg-error "must return .int" }
+{
         for(int i = 0; i < keys;) std::cout << key[i++] << " ";
         std::endl(std::cout);
 }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.brendan/crash55.C
--- gcc/testsuite/g++.old-deja/g++.brendan/crash55.C	1 May 2003 02:02:34 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.brendan/crash55.C	23 Sep 2004 06:21:15 -0000
@@ -1,10 +1,10 @@
-// { dg-do assemble  }
+// { dg-do compile }
 // GROUPS passed old-abort
-      extern f(int);// { dg-error "" }  ambiguates.*
+      extern int f(int); // { dg-error "ambiguates" }
 
-      int& f(int x)
-      {// { dg-error "" }  new declaration.*
-          int local;// { dg-error "" }  warning
+      int& f(int x)  // { dg-error "new declaration" }
+      {
+          int local; // { dg-error "reference to local" }
 
           local = x+2;
       
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.brendan/crash56.C
--- gcc/testsuite/g++.old-deja/g++.brendan/crash56.C	25 Sep 2003 12:51:39 -0000	1.8
+++ gcc/testsuite/g++.old-deja/g++.brendan/crash56.C	23 Sep 2004 06:21:15 -0000
@@ -20,16 +20,16 @@ public:
     class Vix {
     public:
 	Vix();
-	friend int operator==(void *v, const Vix& x)
-	    { return v == x.item; }// { dg-error "" } list of candidates
-	friend int operator==(const Vix& x, void *v)
-	    { return v == x.item; }// { dg-error "" } candidate for call
+	friend int operator==(void *v, const Vix& x) // { dg-error "operator==" }
+	    { return v == x.item; }
+	friend int operator==(const Vix& x, void *v) // { dg-error "operator==" }
+	    { return v == x.item; }
 	friend int operator!=(void *v, const Vix& x)
 	    { return v != x.item; }
 	friend int operator!=(const Vix& x, void *v)
 	    { return v != x.item; }
-	friend int operator==(const Vix& x1, const Vix& x2)
-	    { return x1.owner == x2.owner && x1.item == x2.item; }// { dg-error "" } candidate for call
+	friend int operator==(const Vix& x1, const Vix& x2) // { dg-error "operator==" }
+	    { return x1.owner == x2.owner && x1.item == x2.item; }
 	friend int operator!=(const Vix& x1, const Vix& x2)
 	    { return x1.owner != x2.owner || x1.item != x2.item; }
 	bool first;		 
@@ -343,8 +343,8 @@ operator>=(const SetLD<T>& a, const SetL
 class String { };
 class IcaseString: public String { };
 template <> class SetLD< IcaseString >: public SetLD<    String  > {	public:	 SetLD (): SetLD<    String  >() { };	 SetLD (const ListD<   IcaseString  >& other): SetLD<    String  >()	{ ListD<   IcaseString  >::Vix x;	for (other.first(x); 0 != x; other.next(x))	add(other(x)); };	 SetLD (const  SetLD & other): SetLD<    String  >(other) { };	const    IcaseString  & operator()(const Vix& x) const	{ return (   IcaseString  &) SetLD<    String  >::operator()(x); }	}; 	typedef SetLD<  String > SetLD_String_IcaseString_old_tmp99;	typedef SetLD< IcaseString > SetLD_String_IcaseString_new_tmp99;	
-inline int	 operator== (const SetLD_String_IcaseString_new_tmp99& a,	const SetLD_String_IcaseString_new_tmp99& b)
-{// { dg-error "" } candidate for call
+inline int	 operator== (const SetLD_String_IcaseString_new_tmp99& a,	const SetLD_String_IcaseString_new_tmp99& b) // { dg-error "operator==" }
+{
 const SetLD_String_IcaseString_old_tmp99& oa = a;
 const SetLD_String_IcaseString_old_tmp99& ob = b;
 return  operator== (oa, ob);	} 	
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.brendan/crash8.C
--- gcc/testsuite/g++.old-deja/g++.brendan/crash8.C	1 May 2003 02:02:34 -0000	1.9
+++ gcc/testsuite/g++.old-deja/g++.brendan/crash8.C	23 Sep 2004 06:21:15 -0000
@@ -1,12 +1,12 @@
-// { dg-do assemble  }
+// { dg-do compile }
 // GROUPS passed old-abort
 template<int a, int b>
-class Elvis
-{ // { dg-error "" } in template.*
+class Elvis // { dg-error "class Elvis" }
+{
 } ;
 
 template<int a>
-class Elvis<0>
-{ // { dg-error "" } incorrect number of parameters
+class Elvis<0> // { dg-error "wrong number of template arguments" }
+{
   int geta() { return a ; }
 } ;
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.brendan/enum11.C
--- gcc/testsuite/g++.old-deja/g++.brendan/enum11.C	1 May 2003 02:02:35 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.brendan/enum11.C	23 Sep 2004 06:21:15 -0000
@@ -6,8 +6,8 @@ class X
     {
        oneMask = 0x0000FFFF,
        twoMask  = 0x000F0000,
-       thiMask = 0xFFF00000,
-    }; // { dg-error "" } comma
+       thiMask = 0xFFF00000, // { dg-error "comma at end" }
+    };
     unsigned int foo;
 
 public:
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.brendan/enum8.C
--- gcc/testsuite/g++.old-deja/g++.brendan/enum8.C	1 May 2003 02:02:35 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.brendan/enum8.C	23 Sep 2004 06:21:15 -0000
@@ -6,8 +6,8 @@ class foo1
    enum foo1_enum
    {
       ENUM1,
-      ENUM2,
-   }; // { dg-error "" } comma
+      ENUM2, // { dg-error "comma at end" }
+   };
 };
 
    
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.brendan/enum9.C
--- gcc/testsuite/g++.old-deja/g++.brendan/enum9.C	1 May 2003 02:02:35 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.brendan/enum9.C	23 Sep 2004 06:21:15 -0000
@@ -2,8 +2,8 @@
 // GROUPS passed enums
 enum fig {
     figgy,
-    pudding,
-}; // { dg-error "" } comma
+    pudding,  // { dg-error "comma at end" }
+};
 
 class X {
 public:
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.brendan/friend3.C
--- gcc/testsuite/g++.old-deja/g++.brendan/friend3.C	1 May 2003 02:02:35 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.brendan/friend3.C	23 Sep 2004 06:21:15 -0000
@@ -5,8 +5,8 @@ class B {
    friend class A;
 
    enum {
-      bEnum = 1,
-   }; // { dg-error "" } comma
+      bEnum = 1, // { dg-error "comma at end" }
+   };
 
    int bArray[ bEnum ];
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.brendan/misc14.C
--- gcc/testsuite/g++.old-deja/g++.brendan/misc14.C	1 May 2003 02:02:35 -0000	1.4
+++ gcc/testsuite/g++.old-deja/g++.brendan/misc14.C	23 Sep 2004 06:21:15 -0000
@@ -3,10 +3,11 @@
 class X {
 public:
     enum e {
-	New,// { dg-error "" }  conflicts with other.*
-    }; // { dg-error "" } comma
+	New // { dg-error "conflicts with previous" }
+	,   // { dg-error "comma at end" }
+    };
 
-    static int New(int);// { dg-error "" }  declaration.*
+    static int New(int); // { dg-error "declaration of" }
 };
 
 int main() {}
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.bugs/900402_02.C
--- gcc/testsuite/g++.old-deja/g++.bugs/900402_02.C	1 May 2003 02:02:38 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.bugs/900402_02.C	23 Sep 2004 06:21:15 -0000
@@ -6,17 +6,17 @@
 
 // keywords: arrays, array bound, zero length
 
-typedef int array_type[0];		// { dg-error "" } gets warning only
+typedef int array_type[0];		// { dg-error "zero-size array" }
 
-int array_object_1[0];			// { dg-error "" } gets warning only
+int array_object_1[0];			// { dg-error "zero-size array" }
 
-void function_0 (int formal_array[0])
-{					// { dg-error "" } gets warning only
+void function_0 (int formal_array[0])	// { dg-error "zero-size array" }
+{
 }
 
 void function_2 ()
 {
-  int local_object_array_0[0];		// { dg-error "" } gets warning only
+  int local_object_array_0[0];		// { dg-error "zero-size array" }
 }
 
 int main () { return 0; }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.bugs/900404_03.C
--- gcc/testsuite/g++.old-deja/g++.bugs/900404_03.C	1 May 2003 02:02:38 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.bugs/900404_03.C	23 Sep 2004 06:21:15 -0000
@@ -8,13 +8,13 @@
 
 // keywords: overloading, ambiguity, resolution
 
-void function0 (int i, char c)
-{				// { dg-error "" } 
+void function0 (int i, char c)	// { dg-error "function0" }
+{
   i = c;
 }
 
-void function0 (char c, int i)
-{				// { dg-error "" } 
+void function0 (char c, int i)  // { dg-error "function0" }
+{
   i = c;
 }
 
@@ -22,7 +22,7 @@ char c;
 
 void test ()
 {
-  function0 (c,c);		// { dg-error "" } missed
+  function0 (c,c);		// { dg-error "ambiguous" }
 }
 
 int main () { return 0; }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.bugs/900404_04.C
--- gcc/testsuite/g++.old-deja/g++.bugs/900404_04.C	1 May 2003 02:02:38 -0000	1.5
+++ gcc/testsuite/g++.old-deja/g++.bugs/900404_04.C	23 Sep 2004 06:21:15 -0000
@@ -13,6 +13,6 @@
 
 int i;
 
-;			// { dg-error "" } 
+;			// { dg-error "extra ';'" } 
 
 int main () { return 0; }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.bugs/900428_03.C
--- gcc/testsuite/g++.old-deja/g++.bugs/900428_03.C	1 May 2003 02:02:38 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.bugs/900428_03.C	23 Sep 2004 06:21:15 -0000
@@ -18,15 +18,15 @@ public:
 };
 
 struct_0::struct_0 (int i) { }
-struct_0::struct_0 (int, int) { } // { dg-error "" } xref from below
+struct_0::struct_0 (int, int) { } // { dg-error "is private" }
 
 struct struct_1 : public struct_0 {
 
   struct_1 ();
 };
 
-struct_1::struct_1 () : struct_0 (8,9)
-{				// { dg-error "" } 
+struct_1::struct_1 () : struct_0 (8,9) // { dg-error "within this context" }
+{
 }
 
 struct struct_2 {
@@ -35,11 +35,8 @@ struct struct_2 {
   struct_2 ();
 };
 
-// g++ catches the following error (but does so only at the line with the 
-// closing curly brace).
-
-struct_2::struct_2 () : struct_2_data_member (8,9)
-{				// { dg-error "" } should be up one line
+struct_2::struct_2 () : struct_2_data_member (8,9) // { dg-error "within this context" }
+{
 }
 
 int main () { return 0; }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.jason/crash4.C
--- gcc/testsuite/g++.old-deja/g++.jason/crash4.C	1 May 2003 02:02:40 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.jason/crash4.C	23 Sep 2004 06:21:15 -0000
@@ -16,8 +16,8 @@ public:
 };
 
 template <class T>
-const ccObjectInfo& cc_Array<T>::repInvariant(int) const
-{  return *this /* *this is required here */; } // { dg-error "" } redefined
+const ccObjectInfo& cc_Array<T>::repInvariant(int) const  // { dg-error "previously declared" }
+{  return *this /* *this is required here */; }
 
 template <class T>
 class ccArray :public ccObjectInfo
@@ -32,7 +32,7 @@ class ccObjArray : public ccArray<T>
 }; 
 
 template <class T>
-const ccObjectInfo& cc_Array<T>::repInvariant(int) const
-{  return 0; }			// { dg-error "" } causes compiler segfault
+const ccObjectInfo& cc_Array<T>::repInvariant(int) const // { dg-error "redefinition" }
+{  return 0; }
 
 typedef ccObjArray< double>	ccROIRuns;	 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.jason/overload21.C
--- gcc/testsuite/g++.old-deja/g++.jason/overload21.C	1 May 2003 02:02:40 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.jason/overload21.C	23 Sep 2004 06:21:15 -0000
@@ -1,13 +1,13 @@
 // { dg-do assemble  }
 struct X {
-  void f (int = 4, char = 'r');	// { dg-error "" } 
-  void g (int = 4, char = 'r');	// { dg-error "" } 
+  void f (int = 4, char = 'r');	// { dg-error "previous specification" } 
+  void g (int = 4, char = 'r');	// { dg-error "previous specification" } 
 };
 
 void
-X::f (int i = 4, char x = 'r')
-{ }				// { dg-error "" } duplicate default args
+X::f (int i = 4, char x = 'r') // { dg-error "default argument" }
+{ }
 
 void
-X::g (int i = 9, char x = 's')
-{ }				// { dg-error "" } duplicate default args
+X::g (int i = 9, char x = 's') // { dg-error "default argument" }
+{ }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.jason/redecl1.C
--- gcc/testsuite/g++.old-deja/g++.jason/redecl1.C	1 May 2003 02:02:40 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.jason/redecl1.C	23 Sep 2004 06:21:15 -0000
@@ -3,11 +3,11 @@ class A
 {
 public:
     A (const A& ccref);
-    friend A const re (const A& v1); // { dg-error "" } 
+    friend A const re (const A& v1); // { dg-error "ambiguates" } 
 };
 
 A // const
-re (const A& ref)
-{				// { dg-error "" } mismatched decls
+re (const A& ref) // { dg-error "new declaration" }
+{
     return A (ref);
 }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.jason/report.C
--- gcc/testsuite/g++.old-deja/g++.jason/report.C	15 Jun 2004 20:38:40 -0000	1.12
+++ gcc/testsuite/g++.old-deja/g++.jason/report.C	23 Sep 2004 06:21:15 -0000
@@ -50,8 +50,8 @@ typedef int const * bart ();
 typedef bart const * const * bar2;
 typedef bart volatile * const * bar2v;
 
-bar2 baz (X::Y y)
-{				// { dg-error "" } in this context
+bar2 baz (X::Y y)	        // { dg-error "" } in this context
+{
   X::Y f;			// { dg-error "" } in this context
   bar2 wa [5];
   wa[0] = baz(f);
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.jason/rfg10.C
--- gcc/testsuite/g++.old-deja/g++.jason/rfg10.C	1 May 2003 02:02:41 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.jason/rfg10.C	23 Sep 2004 06:21:15 -0000
@@ -6,5 +6,6 @@
 enum COLOR
 {
     red,
-    green = ULONG_MAX, blue
-};				// { dg-error "" } enum overflow
+    green = ULONG_MAX,
+    blue // { dg-error "overflow in enumeration" }
+};
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.jason/template30.C
--- gcc/testsuite/g++.old-deja/g++.jason/template30.C	1 May 2003 02:02:41 -0000	1.4
+++ gcc/testsuite/g++.old-deja/g++.jason/template30.C	23 Sep 2004 06:21:15 -0000
@@ -3,8 +3,8 @@ template <class T, class U>    
 int func(U, T);			// { dg-error "" } ref below
 
 template <class T, class U>    
-int func(T, U)
-{				// { dg-error "" } ref below
+int func(T, U)			// { dg-error "" } ref below
+{
         return 2;
 }
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.law/arm12.C
--- gcc/testsuite/g++.old-deja/g++.law/arm12.C	1 May 2003 02:02:42 -0000	1.4
+++ gcc/testsuite/g++.old-deja/g++.law/arm12.C	23 Sep 2004 06:21:15 -0000
@@ -22,8 +22,8 @@ public:
   Y();
 };
 
-X::X()
-{// { dg-error "" } .*
+X::X() // { dg-error "is private" }
+{
   std::cout << "X::X()" << std::endl;
 }
 
@@ -32,8 +32,8 @@ void X::f()
   std::cout << "X::f()" << std::endl;
 }
 
-Y::Y()
-{// { dg-error "" }  within this
+Y::Y() // { dg-error "within this context" }
+{
   std::cout << "Y::Y()" << std::endl;
 }
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.law/ctors5.C
--- gcc/testsuite/g++.old-deja/g++.law/ctors5.C	1 May 2003 02:02:42 -0000	1.4
+++ gcc/testsuite/g++.old-deja/g++.law/ctors5.C	23 Sep 2004 06:21:15 -0000
@@ -5,7 +5,7 @@
 // Date: Tue, 1 Sep 92 10:38:44 EDT
 
 class X
-{ // { dg-error "" } candidate
+{ // { dg-error "X::X" } implicit constructor
   private:
     int x;
   public:
@@ -20,14 +20,14 @@ class Y
   public:
     Y();
 }
-X::X( int xi )
-{// { dg-error "" }  return.*
+X::X( int xi ) // { dg-error "return type|X::X" }
+{
     x = xi;
 }
 
 const X X::x0( 0 );
 
-Y::Y()
-{// { dg-error "" }  no mat
+Y::Y() // { dg-error "no match" }
+{
     xx = X::x0;
 }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.law/cvt20.C
--- gcc/testsuite/g++.old-deja/g++.law/cvt20.C	1 May 2003 02:02:42 -0000	1.4
+++ gcc/testsuite/g++.old-deja/g++.law/cvt20.C	23 Sep 2004 06:21:15 -0000
@@ -9,12 +9,12 @@
 
 // Compiles fine with Sun CC 2.1
 
-void f(char *& x)
-{// { dg-error "" } location of error
+void f(char *& x) // { dg-error "passing argument" }
+{
   x++;
 }
 
 int main()
 {
-  f ("foo");// { dg-error "" } init of non-const ref from char*
+  f ("foo"); // { dg-error "invalid initialization" }
 }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.law/init10.C
--- gcc/testsuite/g++.old-deja/g++.law/init10.C	1 May 2003 02:02:43 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.law/init10.C	23 Sep 2004 06:21:15 -0000
@@ -20,7 +20,7 @@ public:
         b();
 };
 
-b::b() : three(this)
-{ // { dg-error "" } bad array initializer
+b::b() : three(this)  // { dg-error "bad array initializer" }
+{
 }
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.law/init8.C
--- gcc/testsuite/g++.old-deja/g++.law/init8.C	1 May 2003 02:02:43 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.law/init8.C	23 Sep 2004 06:21:15 -0000
@@ -8,15 +8,15 @@
 
 
 const int ic = 1;
-void f(int& arg)
-{ // { dg-error "" } argument 1
+void f(int& arg)  // { dg-error "passing argument 1" }
+{
         if (arg) ;
 }
 const int& icr = ic;
 
 int main(void)
 {
-  f(icr);   // g++ does not give error here// { dg-error "" } .*
+  f(icr);   // { dg-error "invalid initialization" }
 
   return 0;
 }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.law/visibility17.C
--- gcc/testsuite/g++.old-deja/g++.law/visibility17.C	1 May 2003 02:02:43 -0000	1.6
+++ gcc/testsuite/g++.old-deja/g++.law/visibility17.C	23 Sep 2004 06:21:15 -0000
@@ -31,24 +31,24 @@ private:
   int num_;
 };
 
-Base::Base()
-{ // { dg-error "" } private
+Base::Base() // { dg-error "is private" }
+{
   name_ = std::strcpy(new char[std::strlen(" ") + 1], " ");
 }
 
-Base::Base(char* str)
-{ // { dg-error "" } private
+Base::Base(char* str) // { dg-error "is private" }
+{
   if(str != NULL)
     name_ = std::strcpy(new char[std::strlen(str) + 1], str);
 }
 
-Derived::Derived(int n, char* str) : Base(str)
-{// { dg-error "" } .*
+Derived::Derived(int n, char* str) : Base(str) // { dg-error "within this context" }
+{
   num_ = n;
 }
 
-Derived::Derived(int n) : Base()
-{// { dg-error "" } .*
+Derived::Derived(int n) : Base() // { dg-error "within this context" }
+{
   num_ = n;
 }
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.law/visibility7.C
--- gcc/testsuite/g++.old-deja/g++.law/visibility7.C	1 May 2003 02:02:43 -0000	1.5
+++ gcc/testsuite/g++.old-deja/g++.law/visibility7.C	23 Sep 2004 06:21:15 -0000
@@ -15,10 +15,10 @@ class A {
     {}
   virtual ~A()
     {}
-  virtual void Number(int c)
-    { number = c; } // { dg-error "" } private
-  virtual int Number()
-    { return number; } // { dg-error "" } private
+  virtual void Number(int c) // { dg-error "inaccessible" }
+    { number = c; }
+  virtual int Number() // { dg-error "inaccessible" }
+    { return number; }
 };
 
 class B : private A {
@@ -53,9 +53,9 @@ class C {
   // and they should not be able to do so
   //
   virtual void setBValue(int i) 
-    { if (bobject) bobject->Number(i); }// { dg-error "" } .*
+    { if (bobject) bobject->Number(i); } // { dg-error "this context|accessible base" }
   virtual int getBValue()
-    { if (bobject) { return bobject->Number(); } return 0; }// { dg-error "" } .*
+    { if (bobject) { return bobject->Number(); } return 0; } // { dg-error "this context|accessible base" }
 };
 
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.mike/net8.C
--- gcc/testsuite/g++.old-deja/g++.mike/net8.C	1 May 2003 02:02:45 -0000	1.4
+++ gcc/testsuite/g++.old-deja/g++.mike/net8.C	23 Sep 2004 06:21:15 -0000
@@ -11,22 +11,22 @@ public:
   int bar;
 };
 
-void func(Base&);		// { dg-error "" } 
+void func(Base&);			// { dg-error "passing argument 1" } 
 
 void func2(const Derived& d) {
-  func(d);			// { dg-error "" } this is bad
+  func(d);				// { dg-error "invalid initialization" }
 }
 
 void
-foo (int& a)
-{				// { dg-error "" } 
+foo (int& a)				// { dg-error "in passing argument 1" } 
+{
 }
 
 int main ()
 {
   int b;
   const int*const a = &b;
-  *a = 10;				// { dg-error "" } it's const
-  foo (*a);				// { dg-error "" } it's const
+  *a = 10;				// { dg-error "read-only location" }
+  foo (*a);				// { dg-error "invalid initialization" }
   return 0;
 }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.mike/p646.C
--- gcc/testsuite/g++.old-deja/g++.mike/p646.C	17 Jun 2004 21:53:45 -0000	1.10
+++ gcc/testsuite/g++.old-deja/g++.mike/p646.C	23 Sep 2004 06:21:15 -0000
@@ -132,8 +132,8 @@ warn_foo_parm_returns_foo (foo f)
   f;
 }                              // { dg-warning "" } control reaches end
 
-main ()
-{				// { dg-warning "" } no type
+main ()			       // { dg-warning "" } no type
+{
   int ii = return_1 ();
   if (ii != 1)
     abort_because ("wrong value returned");
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.mike/p700.C
--- gcc/testsuite/g++.old-deja/g++.mike/p700.C	8 May 2003 23:38:03 -0000	1.9
+++ gcc/testsuite/g++.old-deja/g++.mike/p700.C	23 Sep 2004 06:21:15 -0000
@@ -223,8 +223,8 @@ inline  void  Int::operator >>=(const in
 { rep >>= b;  ; }
 
 
-inline  int& operator  = (int& a,  const Int &   b)
-{ a = b.Int::val(); return a;}	// { dg-warning "" } 
+inline  int& operator  = (int& a,  const Int &   b)	// { dg-warning "" } 
+{ a = b.Int::val(); return a;}
 inline  int& operator += (int& a,  const Int &   b)
 { a += b.Int::val(); return a; }
 inline  int& operator -= (int& a,  const Int &   b)
@@ -562,8 +562,8 @@ inline  void  Char::operator >>=(const c
 { rep >>= b;  ; }
 
 
-inline  char& operator  = (char& a,  const Char &   b)
-{ a = b.Char::val(); return a;}	// { dg-warning "" } 
+inline  char& operator  = (char& a,  const Char &   b)	// { dg-warning "" } 
+{ a = b.Char::val(); return a;}
 inline  char& operator += (char& a,  const Char &   b)
 { a += b.Char::val(); return a; }
 inline  char& operator -= (char& a,  const Char &   b)
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.mike/p701.C
--- gcc/testsuite/g++.old-deja/g++.mike/p701.C	1 May 2003 02:02:46 -0000	1.5
+++ gcc/testsuite/g++.old-deja/g++.mike/p701.C	23 Sep 2004 06:21:15 -0000
@@ -7,8 +7,8 @@ extern "C" 
 }
 
 
-void Munge(int& x) 
-{				// { dg-error "" } referenced below
+void Munge(int& x) 	// { dg-error "passing argument 1" }
+{
    x = 2;
 }
 
@@ -24,7 +24,7 @@ class A 
 void
 A::Safe() const 
 {
-   Munge(i);	// { dg-error "" } should not be able to modify a const object
+   Munge(i);	        // { dg-error "invalid initialization" }
 }
 
 int main()
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.mike/p811.C
--- gcc/testsuite/g++.old-deja/g++.mike/p811.C	1 May 2003 02:02:46 -0000	1.4
+++ gcc/testsuite/g++.old-deja/g++.mike/p811.C	23 Sep 2004 06:21:15 -0000
@@ -512,25 +512,25 @@ class Y {
 public:
     Y() {}
     virtual const char *stringify() = 0;
-    virtual char *stringify2() const = 0; // { dg-error "" } 
+    virtual char *stringify2() const = 0; // { dg-error "overriding" } 
 };
 
 class X: public Y {
 public:
     X(): Y() {}
-    char *stringify();		// { dg-error "" } ok
-    const char *stringify2() const;  // { dg-error "" } ok
+    char *stringify();		// { dg-error "candidate" }
+    const char *stringify2() const;  // { dg-error "candidate|conflicting return type" }
 };
 
 char *
-X::stringify() const
-{ // { dg-error "" } ok
+X::stringify() const  // { dg-error "does not match" }
+{
     return "stringify";
 }
 
 const char *
-X::stringify2()
-{ // { dg-error "" } ok
+X::stringify2()   // { dg-error "does not match" }
+{
     return "stringify2";
 }
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.ns/template13.C
--- gcc/testsuite/g++.old-deja/g++.ns/template13.C	2 Aug 2004 06:25:36 -0000	1.7
+++ gcc/testsuite/g++.old-deja/g++.ns/template13.C	23 Sep 2004 06:21:15 -0000
@@ -1,23 +1,23 @@
-// { dg-do assemble { xfail *-*-* } }
+// { dg-do compile }
 // Templates defined outside must be declared inside
 namespace bar
 {
   // trick it to provide some prior declaration
   template<class T>
   void foo(); // { dg-error "definition" }
-  template<class T>class X; // { dg-error "" } previous declaration
+  template<class T>class X; // { dg-error "previous declaration" }
 }
 
 template <typename T>
 T const
-bar::foo(T const &a)    
-{                        // { dg-error "" "" { xfail *-*-* } } not declared in bar - 
+bar::foo(T const &a)     // { dg-error "" "" { xfail *-*-* } } not declared in bar - 
+{
   return a;
 }
 
-template<> void bar::foo<int>()
-{                        // { dg-error "" }
+template<> void bar::foo<int>()     // { dg-error "different namespace" }
+{
 }
 
 template<class T,class U>
-class bar::X{};         // { dg-error "" } does not match declaration
+class bar::X{};         // { dg-error "1 template parameter" }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.other/array3.C
--- gcc/testsuite/g++.old-deja/g++.other/array3.C	1 May 2003 02:02:48 -0000	1.2
+++ gcc/testsuite/g++.old-deja/g++.other/array3.C	23 Sep 2004 06:21:15 -0000
@@ -20,6 +20,6 @@ class B
 };
 
 B::B (const A a[])
-  : ary(a)
-{        // { dg-error "" } bad array initializer
+  : ary(a)        // { dg-error "bad array initializer" }
+{
 }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.other/crash25.C
--- gcc/testsuite/g++.old-deja/g++.other/crash25.C	1 May 2003 02:02:48 -0000	1.5
+++ gcc/testsuite/g++.old-deja/g++.other/crash25.C	23 Sep 2004 06:21:15 -0000
@@ -7,10 +7,10 @@ public:
   virtual ~X();
 }
 
-X::x()
-{				// { dg-error "" } 
+X::x()	// { dg-error "return type|member function" }
+{
 }
 
-X::~x()                         // { dg-error "" } 
+X::~x()	// { dg-error "expected class-name" }
 {				
 }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.other/dtor3.C
--- gcc/testsuite/g++.old-deja/g++.other/dtor3.C	1 May 2003 02:02:49 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.other/dtor3.C	23 Sep 2004 06:21:15 -0000
@@ -31,8 +31,8 @@ struct S5
   ~S5(); 
 };
 
-S5::~S5(float) 
-{ // { dg-error "" } destructors may not have parameters
+S5::~S5(float)  // { dg-error "" } destructors may not have parameters
+{
 }
 
 
@@ -43,8 +43,8 @@ struct S6
 };
 
 template <class T>
-S6<T>::~S6(float)
-{ // { dg-error "" } destructors may not have parameters
+S6<T>::~S6(float)   // { dg-error "" } destructors may not have parameters
+{
 }
 
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.other/dtor4.C
--- gcc/testsuite/g++.old-deja/g++.other/dtor4.C	1 May 2003 02:02:49 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.other/dtor4.C	23 Sep 2004 06:21:15 -0000
@@ -4,8 +4,8 @@ struct S1 {
   ~S1(); // { dg-error "" } candidate
 };
 
-S1::~S1() const
-{ // { dg-error "" } prototype does not match 
+S1::~S1() const // { dg-error "" } prototype does not match 
+{
 }
 
 
@@ -20,8 +20,8 @@ struct S3 {
 };
 
 template <class T>
-S3<T>::~S3() volatile
-{ // { dg-error "" } prototype does not match 
+S3<T>::~S3() volatile  // { dg-error "" } prototype does not match 
+{
 }
 
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.other/main1.C
--- gcc/testsuite/g++.old-deja/g++.other/main1.C	1 May 2003 02:02:50 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.other/main1.C	23 Sep 2004 06:21:15 -0000
@@ -1,13 +1,12 @@
-// { dg-do assemble  }
-// Build don't linK:
+// { dg-do compile }
 
-int main()
-{ // { dg-error "" } invalid redeclaration of
+int main()  // { dg-error "previous declaration" }
+{
   return 0;
 }
 
 
-int main(int, const char**)
-{ // { dg-error "" } as
+int main(int, const char**) // { dg-error "conflicts" }
+{
   return 0;
 }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.other/warn7.C
--- gcc/testsuite/g++.old-deja/g++.other/warn7.C	1 May 2003 02:02:52 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.other/warn7.C	23 Sep 2004 06:21:15 -0000
@@ -34,12 +34,12 @@ struct Y
 };
 void bar (int);
 
-Y::Y(int i)
-{ // { dg-warning "" } unused parameter
+Y::Y(int i)  // { dg-warning "unused parameter" }
+{
 }
-void Y::bar (int i) 
-{ // { dg-warning "" } unused parameter
+void Y::bar (int i)  // { dg-warning "unused parameter" }
+{
 }
-void bar (int i)
-{ // { dg-warning "" } unused parameter
+void bar (int i) // { dg-warning "unused parameter" }
+{
 }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.pt/crash11.C
--- gcc/testsuite/g++.old-deja/g++.pt/crash11.C	1 May 2003 02:02:53 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.pt/crash11.C	23 Sep 2004 06:21:15 -0000
@@ -8,6 +8,6 @@ class A
 };
 
 
-template <class j> class A::A_impl 
-{ // { dg-error "" } does not declare a template
+template <class j> class A::A_impl // { dg-error "does not declare a template" }
+{
 };
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.pt/crash36.C
--- gcc/testsuite/g++.old-deja/g++.pt/crash36.C	15 Aug 2003 10:46:50 -0000	1.7
+++ gcc/testsuite/g++.old-deja/g++.pt/crash36.C	23 Sep 2004 06:21:15 -0000
@@ -28,7 +28,7 @@ struct list {
   };
   
   reverse_iterator<list_iterator<T> > rbegin()
-    { return reverse_iterator<list_iterator<T> > // { dg-error "" } no type|instantiated here
+    { return reverse_iterator<list_iterator<T> >
 	(list_iterator<T>(Head->next())); } // { dg-error "" } not declared
 };
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.pt/spec22.C
--- gcc/testsuite/g++.old-deja/g++.pt/spec22.C	1 May 2003 02:02:55 -0000	1.4
+++ gcc/testsuite/g++.old-deja/g++.pt/spec22.C	23 Sep 2004 06:21:15 -0000
@@ -9,7 +9,7 @@ struct S
 
 
 template <class T> 
-template <> // { dg-error "" } enclosing classes not specialized
-void S<T>::f<int> () 
-{ // { dg-error "" } template does not match any declaration
+template <> // { dg-error "enclosing class templates|invalid explicit specialization" }
+void S<T>::f<int> ()  // { dg-error "does not match|invalid function declaration" }
+{
 }
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.pt/spec9.C
--- gcc/testsuite/g++.old-deja/g++.pt/spec9.C	1 May 2003 02:02:55 -0000	1.3
+++ gcc/testsuite/g++.old-deja/g++.pt/spec9.C	23 Sep 2004 06:21:15 -0000
@@ -14,8 +14,8 @@ int main()
 }
 
 template <>
-int f(int i) 
-{             // { dg-error "" } specialization of f<int>(int) after instantiation
+int f(int i)   // { dg-error "specialization\[^\n\]*after instantiation" }
+{
   return 1;
 }
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.pt/ttp52.C
--- gcc/testsuite/g++.old-deja/g++.pt/ttp52.C	1 May 2003 02:02:56 -0000	1.4
+++ gcc/testsuite/g++.old-deja/g++.pt/ttp52.C	23 Sep 2004 06:21:15 -0000
@@ -7,12 +7,10 @@ template<class Key, 
          template<class, class > class MapT> 
 class base 
 {
-  
 };
 
 // specialization
 template<class Key, class Value>
-class base<Key, Value, mymap<int, int > >	
-{						// { dg-error "" } type/value mismatch
-  
+class base<Key, Value, mymap<int, int > > // { dg-error "type/value|class template" }
+{
 };
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.robertl/eb103.C
--- gcc/testsuite/g++.old-deja/g++.robertl/eb103.C	1 May 2003 02:02:58 -0000	1.4
+++ gcc/testsuite/g++.old-deja/g++.robertl/eb103.C	23 Sep 2004 06:21:15 -0000
@@ -4,8 +4,8 @@
 template <int nlimb, int i>
 inline unsigned f (unsigned* ptr);
 template <int nlimb>
-inline unsigned f<nlimb,nlimb> (unsigned* ptr)
-{                        //{ dg-error "" } partial specialization of function?
+inline unsigned f<nlimb,nlimb> (unsigned* ptr) // { dg-error "function template partial specialization" }
+{
   return 1;
 }
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.robertl/eb121.C
--- gcc/testsuite/g++.old-deja/g++.robertl/eb121.C	1 May 2003 02:02:58 -0000	1.5
+++ gcc/testsuite/g++.old-deja/g++.robertl/eb121.C	23 Sep 2004 06:21:15 -0000
@@ -3,12 +3,12 @@ class A {
 private:
   int i1_;
 public:
-  void f(int const i1 = 1); // { dg-error "" } previous specification
+  void f(int const i1 = 1); // { dg-error "previous specification" }
 };
 
 void
-A::f(int const i1 = 1)
-{                          // { dg-error "" } duplicate default argument
+A::f(int const i1 = 1) // { dg-error "default argument given" }
+{
   i1_ = i1;
 }
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.robertl/eb22.C
--- gcc/testsuite/g++.old-deja/g++.robertl/eb22.C	1 May 2003 02:02:58 -0000	1.5
+++ gcc/testsuite/g++.old-deja/g++.robertl/eb22.C	23 Sep 2004 06:21:15 -0000
@@ -11,13 +11,13 @@ public:
         operator int() const {return 2;}
 };
 
-bool operator==(const MyInt& a, const int& b)
-{                                               // { dg-error "" } candidate
+bool operator==(const MyInt& a, const int& b)   // { dg-error "" } candidate
+{
         return (int)a == b;
 }
 
-bool operator==(const MyInt& a, const MyInt& b)
-{                                               // { dg-error "" } candidate
+bool operator==(const MyInt& a, const MyInt& b) // { dg-error "" } candidate
+{
         return (int)a == (int)b;
 }
 
===================================================================
Index: gcc/testsuite/g++.old-deja/g++.robertl/eb8.C
--- gcc/testsuite/g++.old-deja/g++.robertl/eb8.C	1 May 2003 02:02:58 -0000	1.4
+++ gcc/testsuite/g++.old-deja/g++.robertl/eb8.C	23 Sep 2004 06:21:15 -0000
@@ -6,8 +6,8 @@ public:
   operator <<(char *);        //{ dg-error "" } no return type
 };
 
-void main()
-{                             //{ dg-error "" } wrong return type for main
+void main()		      // { dg-error "must return .int" }
+{
   foo f;
   f << (void*)0;
 }
===================================================================
Index: libstdc++-v3/testsuite/20_util/memory/auto_ptr/assign_neg.cc
--- libstdc++-v3/testsuite/20_util/memory/auto_ptr/assign_neg.cc	2 Jul 2004 20:44:06 -0000	1.1
+++ libstdc++-v3/testsuite/20_util/memory/auto_ptr/assign_neg.cc	23 Sep 2004 06:21:17 -0000
@@ -46,5 +46,5 @@ main()
   test01();
   return 0;
 }
-// { dg-error "candidates" "" { target *-*-* } 223 } 
-// { dg-error "std::auto_ptr" "" { target *-*-* } 353 } 
+// { dg-error "candidates" "" { target *-*-* } 222 } 
+// { dg-error "std::auto_ptr" "" { target *-*-* } 352 } 
===================================================================
Index: libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc
--- libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc	26 Mar 2004 00:38:56 -0000	1.4
+++ libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc	23 Sep 2004 06:21:19 -0000
@@ -41,5 +41,5 @@ void test01()
   test &= itr == mapByName.end(); // { dg-error "no" } 
 }
  
-// { dg-error "candidates are" "" { target *-*-* } 209 } 
-// { dg-error "candidates are" "" { target *-*-* } 213 }
+// { dg-error "candidates are" "" { target *-*-* } 208 } 
+// { dg-error "candidates are" "" { target *-*-* } 212 }
===================================================================
Index: libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc
--- libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc	26 Mar 2004 00:38:57 -0000	1.4
+++ libstdc++-v3/testsuite/23_containers/set/operators/1_neg.cc	23 Sep 2004 06:21:19 -0000
@@ -39,6 +39,5 @@ void test01()
   test &= itr == setByName.end(); // { dg-error "no" } 
 }
 
-// { dg-error "candidates are" "" { target *-*-* } 282 } 
-// { dg-error "candidates are" "" { target *-*-* } 286 }
-
+// { dg-error "candidates are" "" { target *-*-* } 281 } 
+// { dg-error "candidates are" "" { target *-*-* } 285 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]