diff mbox

[C++] PR 71238 ("Undeclared function message imprecisely points to error column")

Message ID 574C5F67.4020803@oracle.com
State New
Headers show

Commit Message

Paolo Carlini May 30, 2016, 3:42 p.m. UTC
Hi,

this diagnostic bug report is about an incorrect column (normally the 
final closed parenthesis) for error messages emitted by 
unqualified_fn_lookup_error. The substance of the fix is obvious - pass 
an appropriate column information to the function - and it handles 
correctly all the instances I could find in the C++ testsuite, but there 
are a few implementation details that certainly could be different. Note 
that I also tried to be quite conservative, thus actively avoid 
UNKNOWN_LOCATION to ever get through. Eventually I'm proposing to change 
unqualified_fn_lookup_error to take a cp_expr instead of my initial idea 
of adding a location_t parameter: this way the call from 
cp_parser_postfix_expression - which accounts for about a third of the 
locations fixed in the testsuite - is automatically handled and only the 
call from perform_koenig_lookup needs a little adjustment, to wrap the 
location in a cp_expr together with the identifier. But admittedly I 
didn't follow in detail the discussion which led to the introduction of 
cp_expr, I'm not sure this kind of wrapping counts as an "appropriate" 
use. Tested x86_64-linux.

Thanks,
Paolo.

//////////////////////////
/cp
2016-05-30  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/71238
	* lex.c (unqualified_name_lookup_error): Take a location too.
	(unqualified_fn_lookup_error): Take a cp_expr.
	* cp-tree.h (unqualified_name_lookup_error,
	unqualified_fn_lookup_error): Adjust declarations.
	* semantics.c (perform_koenig_lookup): Adjust
	unqualified_fn_lookup_error call, pass the location of
	the identifier too as part of a cp_expr.

/testsuite
2016-05-30  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/71238
	* g++.dg/parse/pr71238.C: New.
	* g++.dg/concepts/friend1.C: Test column numbers too.
	* g++.dg/cpp0x/initlist31.C: Likewise.
	* g++.dg/cpp0x/pr51420.C: Likewise.
	* g++.dg/cpp0x/udlit-declare-neg.C: Likewise.
	* g++.dg/cpp0x/udlit-member-neg.C: Likewise.
	* g++.dg/ext/builtin3.C: Likewise.
	* g++.dg/lookup/friend12.C: Likewise.
	* g++.dg/lookup/friend7.C: Likewise.
	* g++.dg/lookup/koenig1.C: Likewise.
	* g++.dg/lookup/koenig5.C: Likewise.
	* g++.dg/lookup/used-before-declaration.C: Likewise.
	* g++.dg/overload/koenig1.C: Likewise.
	* g++.dg/template/crash65.C: Likewise.
	* g++.dg/template/friend57.C: Likewise.
	* g++.dg/warn/Wshadow-5.C: Likewise.
	* g++.dg/warn/Wunused-8.C: Likewise.
	* g++.old-deja/g++.bugs/900211_01.C: Likewise.
	* g++.old-deja/g++.jason/lineno5.C: Likewise.
	* g++.old-deja/g++.jason/member.C: Likewise.
	* g++.old-deja/g++.jason/report.C: Likewise.
	* g++.old-deja/g++.jason/scoping12.C: Likewise.
	* g++.old-deja/g++.law/visibility20.C: Likewise.
	* g++.old-deja/g++.ns/koenig5.C: Likewise.
	* g++.old-deja/g++.other/static5.C: Likewise.
	* g++.old-deja/g++.pt/overload2.C: Likewise.

Comments

Jason Merrill May 30, 2016, 4:07 p.m. UTC | #1
On 05/30/2016 11:42 AM, Paolo Carlini wrote:
> +unqualified_name_lookup_error (tree name, location_t loc)
>  {
> +  if (loc == UNKNOWN_LOCATION)
> +    loc = location_of (name);

When does this do anything useful?  If name is a DECL, this will give 
the wrong answer.  If name is an IDENTIFIER_NODE, this will give 
UNKNOWN_LOCATION.

Jason
Paolo Carlini May 30, 2016, 4:45 p.m. UTC | #2
Hi,

On 30/05/2016 18:07, Jason Merrill wrote:
> On 05/30/2016 11:42 AM, Paolo Carlini wrote:
>> +unqualified_name_lookup_error (tree name, location_t loc)
>>  {
>> +  if (loc == UNKNOWN_LOCATION)
>> +    loc = location_of (name);
>
> When does this do anything useful?  If name is a DECL, this will give 
> the wrong answer.  If name is an IDENTIFIER_NODE, this will give 
> UNKNOWN_LOCATION.
Indeed, I wasn't sure, as I said, I tried to be conservative, because we 
used to call in that function. I'm going to regression test again with 
input_location instead. Does the patch otherwise looks sane?

Thanks,
Paolo.
Jason Merrill May 30, 2016, 4:59 p.m. UTC | #3
On 05/30/2016 12:45 PM, Paolo Carlini wrote:
> Hi,
>
> On 30/05/2016 18:07, Jason Merrill wrote:
>> On 05/30/2016 11:42 AM, Paolo Carlini wrote:
>>> +unqualified_name_lookup_error (tree name, location_t loc)
>>>  {
>>> +  if (loc == UNKNOWN_LOCATION)
>>> +    loc = location_of (name);
>>
>> When does this do anything useful?  If name is a DECL, this will give
>> the wrong answer.  If name is an IDENTIFIER_NODE, this will give
>> UNKNOWN_LOCATION.
> Indeed, I wasn't sure, as I said, I tried to be conservative, because we
> used to call in that function. I'm going to regression test again with
> input_location instead. Does the patch otherwise looks sane?

The safest choice would be

EXPR_LOCATION_OR_LOC (name, input_location)

OK with that change.

Jason
diff mbox

Patch

Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h	(revision 236880)
+++ cp/cp-tree.h	(working copy)
@@ -5974,8 +5974,9 @@  extern tree build_vtbl_address                  (t
 extern void cxx_dup_lang_specific_decl		(tree);
 extern void yyungetc				(int, int);
 
-extern tree unqualified_name_lookup_error	(tree);
-extern tree unqualified_fn_lookup_error		(tree);
+extern tree unqualified_name_lookup_error	(tree,
+						 location_t = UNKNOWN_LOCATION);
+extern tree unqualified_fn_lookup_error		(cp_expr);
 extern tree build_lang_decl			(enum tree_code, tree, tree);
 extern tree build_lang_decl_loc			(location_t, enum tree_code, tree, tree);
 extern void retrofit_lang_decl			(tree);
Index: cp/lex.c
===================================================================
--- cp/lex.c	(revision 236880)
+++ cp/lex.c	(working copy)
@@ -443,19 +443,22 @@  handle_pragma_java_exceptions (cpp_reader* /*dfile
    IDENTIFIER_NODE) failed.  Returns the ERROR_MARK_NODE.  */
 
 tree
-unqualified_name_lookup_error (tree name)
+unqualified_name_lookup_error (tree name, location_t loc)
 {
+  if (loc == UNKNOWN_LOCATION)
+    loc = location_of (name);
+
   if (IDENTIFIER_OPNAME_P (name))
     {
       if (name != ansi_opname (ERROR_MARK))
-	error ("%qD not defined", name);
+	error_at (loc, "%qD not defined", name);
     }
   else
     {
       if (!objc_diagnose_private_ivar (name))
 	{
-	  error ("%qD was not declared in this scope", name);
-	  suggest_alternatives_for (location_of (name), name);
+	  error_at (loc, "%qD was not declared in this scope", name);
+	  suggest_alternatives_for (loc, name);
 	}
       /* Prevent repeated error messages by creating a VAR_DECL with
 	 this NAME in the innermost block scope.  */
@@ -462,8 +465,7 @@  tree
       if (local_bindings_p ())
 	{
 	  tree decl;
-	  decl = build_decl (input_location,
-			     VAR_DECL, name, error_mark_node);
+	  decl = build_decl (loc, VAR_DECL, name, error_mark_node);
 	  DECL_CONTEXT (decl) = current_function_decl;
 	  push_local_binding (name, decl, 0);
 	  /* Mark the variable as used so that we do not get warnings
@@ -475,13 +477,18 @@  tree
   return error_mark_node;
 }
 
-/* Like unqualified_name_lookup_error, but NAME is an unqualified-id
-   used as a function.  Returns an appropriate expression for
-   NAME.  */
+/* Like unqualified_name_lookup_error, but NAME_EXPR is an unqualified-id
+   NAME, encapsulated with its location in a CP_EXPR, used as a function.
+   Returns an appropriate expression for NAME.  */
 
 tree
-unqualified_fn_lookup_error (tree name)
+unqualified_fn_lookup_error (cp_expr name_expr)
 {
+  tree name = name_expr.get_value ();
+  location_t loc = name_expr.get_location ();
+  if (loc == UNKNOWN_LOCATION)
+    loc = input_location;
+
   if (processing_template_decl)
     {
       /* In a template, it is invalid to write "f()" or "f(3)" if no
@@ -494,7 +501,7 @@  tree
 	 Note that we have the exact wording of the following message in
 	 the manual (trouble.texi, node "Name lookup"), so they need to
 	 be kept in synch.  */
-      permerror (input_location, "there are no arguments to %qD that depend on a template "
+      permerror (loc, "there are no arguments to %qD that depend on a template "
 		 "parameter, so a declaration of %qD must be available",
 		 name, name);
 
@@ -503,7 +510,7 @@  tree
 	  static bool hint;
 	  if (!hint)
 	    {
-	      inform (input_location, "(if you use %<-fpermissive%>, G++ will accept your "
+	      inform (loc, "(if you use %<-fpermissive%>, G++ will accept your "
 		     "code, but allowing the use of an undeclared name is "
 		     "deprecated)");
 	      hint = true;
@@ -512,7 +519,7 @@  tree
       return name;
     }
 
-  return unqualified_name_lookup_error (name);
+  return unqualified_name_lookup_error (name, loc);
 }
 
 /* Wrapper around build_lang_decl_loc(). Should gradually move to
Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 236880)
+++ cp/semantics.c	(working copy)
@@ -2210,6 +2210,7 @@  perform_koenig_lookup (cp_expr fn, vec<tree, va_gc
   tree functions = NULL_TREE;
   tree tmpl_args = NULL_TREE;
   bool template_id = false;
+  location_t loc = fn.get_location ();
 
   if (TREE_CODE (fn) == TEMPLATE_ID_EXPR)
     {
@@ -2245,7 +2246,7 @@  perform_koenig_lookup (cp_expr fn, vec<tree, va_gc
 	{
 	  /* The unqualified name could not be resolved.  */
 	  if (complain)
-	    fn = unqualified_fn_lookup_error (identifier);
+	    fn = unqualified_fn_lookup_error (cp_expr (identifier, loc));
 	  else
 	    fn = identifier;
 	}
Index: testsuite/g++.dg/concepts/friend1.C
===================================================================
--- testsuite/g++.dg/concepts/friend1.C	(revision 236884)
+++ testsuite/g++.dg/concepts/friend1.C	(working copy)
@@ -24,7 +24,7 @@  struct X { } x;
 int main() {
   // f(0); // OK
   f(nt); // { dg-error "cannot call" }
-  f(x);  // { dg-error "not declared" }
+  f(x);  // { dg-error "3:'f' was not declared" }
 
   S<int> si;
   si == si; // OK
Index: testsuite/g++.dg/cpp0x/initlist31.C
===================================================================
--- testsuite/g++.dg/cpp0x/initlist31.C	(revision 236884)
+++ testsuite/g++.dg/cpp0x/initlist31.C	(working copy)
@@ -8,6 +8,6 @@  struct string { string(std::initializer_list<char>
 void f() {
   auto y =
   {
-    string(Equation()) // { dg-error "not declared" }
+    string(Equation()) // { dg-error "12:'Equation' was not declared" }
   }; // { dg-error "unable to deduce" }
 }
Index: testsuite/g++.dg/cpp0x/pr51420.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr51420.C	(revision 236884)
+++ testsuite/g++.dg/cpp0x/pr51420.C	(working copy)
@@ -3,6 +3,6 @@ 
 void
 foo()
 {
-  float x = operator"" _F();  //  { dg-error  "was not declared in this scope" }
+  float x = operator"" _F();  //  { dg-error  "13:'operator\"\"_F' was not declared in this scope" }
   float y = 0_F;  //  { dg-error  "unable to find numeric literal operator" }
 }
Index: testsuite/g++.dg/cpp0x/udlit-declare-neg.C
===================================================================
--- testsuite/g++.dg/cpp0x/udlit-declare-neg.C	(revision 236884)
+++ testsuite/g++.dg/cpp0x/udlit-declare-neg.C	(working copy)
@@ -2,14 +2,14 @@ 
 
 //  Check that undeclared literal operator calls and literals give appropriate errors.
 
-int i = operator"" _Bar('x');  // { dg-error "was not declared in this scope" }
+int i = operator"" _Bar('x');  // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" }
 int j = 'x'_Bar;  // { dg-error "unable to find character literal operator|with|argument" }
 
-int ii = operator"" _BarCharStr("Howdy, Pardner!");  // { dg-error "was not declared in this scope" }
+int ii = operator"" _BarCharStr("Howdy, Pardner!");  // { dg-error "10:'operator\"\"_BarCharStr' was not declared in this scope" }
 int jj = "Howdy, Pardner!"_BarCharStr;  // { dg-error "unable to find string literal operator|Possible missing length argument" }
 
-unsigned long long iULL = operator"" _BarULL(666ULL);  // { dg-error "was not declared in this scope" }
+unsigned long long iULL = operator"" _BarULL(666ULL);  // { dg-error "27:'operator\"\"_BarULL' was not declared in this scope" }
 unsigned long long jULL = 666_BarULL;  // { dg-error "unable to find numeric literal operator" }
 
-long double iLD = operator"" _BarLD(666.0L);  // { dg-error "was not declared in this scope" }
+long double iLD = operator"" _BarLD(666.0L);  // { dg-error "19:'operator\"\"_BarLD' was not declared in this scope" }
 long double jLD = 666.0_BarLD;  // { dg-error "unable to find numeric literal operator" }
Index: testsuite/g++.dg/cpp0x/udlit-member-neg.C
===================================================================
--- testsuite/g++.dg/cpp0x/udlit-member-neg.C	(revision 236884)
+++ testsuite/g++.dg/cpp0x/udlit-member-neg.C	(working copy)
@@ -7,7 +7,7 @@  class Foo
   int operator"" _Bar(char32_t);  // { dg-error "must be a non-member function" }
 };
 
-int i = operator"" _Bar(U'x');  // { dg-error "was not declared in this scope" }
+int i = operator"" _Bar(U'x');  // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" }
 int j = U'x'_Bar;  // { dg-error "unable to find character literal operator" }
 
 int
Index: testsuite/g++.dg/ext/builtin3.C
===================================================================
--- testsuite/g++.dg/ext/builtin3.C	(revision 236884)
+++ testsuite/g++.dg/ext/builtin3.C	(working copy)
@@ -9,6 +9,6 @@  extern "C" int printf(char*, ...); // { dg-message
 }
 
 void foo() {
-  printf("abc"); 		// { dg-error "not declared" }
+  printf("abc"); 		// { dg-error "3:'printf' was not declared" }
   // { dg-message "suggested alternative" "suggested alternative" { target *-*-* } 12 }
 }
Index: testsuite/g++.dg/lookup/friend12.C
===================================================================
--- testsuite/g++.dg/lookup/friend12.C	(revision 236884)
+++ testsuite/g++.dg/lookup/friend12.C	(working copy)
@@ -6,5 +6,5 @@  void foo()
   {
     friend void bar();		// { dg-error "without prior declaration" }
   };
-  bar();			// { dg-error "not declared" }
+  bar();			// { dg-error "3:'bar' was not declared" }
 }
Index: testsuite/g++.dg/lookup/friend7.C
===================================================================
--- testsuite/g++.dg/lookup/friend7.C	(revision 236884)
+++ testsuite/g++.dg/lookup/friend7.C	(working copy)
@@ -11,7 +11,7 @@  int main()
 struct S { friend void g(); friend void h(S); };
 struct T { friend void g(); friend void h(T); };
 void i() {
-  g();			// { dg-error "not declared" }
+  g();			// { dg-error "3:'g' was not declared" }
   S s;
   h(s);
   T t;
Index: testsuite/g++.dg/lookup/koenig1.C
===================================================================
--- testsuite/g++.dg/lookup/koenig1.C	(revision 236884)
+++ testsuite/g++.dg/lookup/koenig1.C	(working copy)
@@ -9,5 +9,5 @@  class X;
 
 void foo() {
   X x(1); // { dg-error "incomplete type" "" }
-  bar(x); // { dg-error "not declared" "" }
+  bar(x); // { dg-error "3:'bar' was not declared" "" }
 }
Index: testsuite/g++.dg/lookup/koenig5.C
===================================================================
--- testsuite/g++.dg/lookup/koenig5.C	(revision 236884)
+++ testsuite/g++.dg/lookup/koenig5.C	(working copy)
@@ -31,12 +31,12 @@  void g (N::A *a, M::B *b, O::C *c)
 {
   One (a); // ok
   One (a, b); // ok
-  One (b); // { dg-error "not declared" }
+  One (b); // { dg-error "3:'One' was not declared" }
   // { dg-message "suggested alternatives" "suggested alternative for One" { target *-*-* } 34 }
 
   Two (c); // ok
   Two (a, c); // ok
-  Two (a); // { dg-error "not declared" }
+  Two (a); // { dg-error "3:'Two' was not declared" }
   // { dg-message "suggested alternatives" "suggested alternative for Two" { target *-*-* } 39 }
   Two (a, a); // error masked by earlier error
   Two (b); // error masked by earlier error
@@ -44,6 +44,6 @@  void g (N::A *a, M::B *b, O::C *c)
   
   Three (b); // ok
   Three (a, b); // ok
-  Three (a); // { dg-error "not declared" }
+  Three (a); // { dg-error "3:'Three' was not declared" }
   // { dg-message "suggested alternatives" "suggested alternative for Three" { target *-*-* } 47 }
 }
Index: testsuite/g++.dg/lookup/used-before-declaration.C
===================================================================
--- testsuite/g++.dg/lookup/used-before-declaration.C	(revision 236884)
+++ testsuite/g++.dg/lookup/used-before-declaration.C	(working copy)
@@ -1,5 +1,5 @@ 
 // Copyroght (C) 2003 Free Software Foundation
 // Origin: PR/12832, Jonathan Wakely <redi@gcc.gnu.org>
 
-void f() { g(); }               // { dg-error "not declared" "" }
+void f() { g(); }               // { dg-error "12:'g' was not declared" "" }
 void g() { }
Index: testsuite/g++.dg/overload/koenig1.C
===================================================================
--- testsuite/g++.dg/overload/koenig1.C	(revision 236884)
+++ testsuite/g++.dg/overload/koenig1.C	(working copy)
@@ -13,7 +13,7 @@  void g ()
 {
   B *bp;
   N::A *ap;
-  f (bp);			// { dg-error "not declared" }
+  f (bp);			// { dg-error "3:'f' was not declared" }
   // { dg-message "suggested alternative" "suggested alternative" { target *-*-* } 16 }
   f (ap);
 }
Index: testsuite/g++.dg/parse/pr71238.C
===================================================================
--- testsuite/g++.dg/parse/pr71238.C	(revision 0)
+++ testsuite/g++.dg/parse/pr71238.C	(working copy)
@@ -0,0 +1,6 @@ 
+// PR c++/71238
+
+int main()
+{
+    int x=myFunc(3234);  // { dg-error "11:'myFunc' was not declared" }
+}
Index: testsuite/g++.dg/template/crash65.C
===================================================================
--- testsuite/g++.dg/template/crash65.C	(revision 236884)
+++ testsuite/g++.dg/template/crash65.C	(working copy)
@@ -3,5 +3,5 @@ 
 struct A
 {
   template<int> template<typename T> friend void foo(T) {} // { dg-error "parameter" }
-  void bar() { foo(0); } // { dg-error "foo" }
+  void bar() { foo(0); } // { dg-error "16:'foo' was not declared" }
 };
Index: testsuite/g++.dg/template/friend57.C
===================================================================
--- testsuite/g++.dg/template/friend57.C	(revision 236884)
+++ testsuite/g++.dg/template/friend57.C	(working copy)
@@ -15,7 +15,7 @@  int
 main ()
 {
   f(1);
-  g(1); // { dg-error "'g' was not declared in this scope" }
+  g(1); // { dg-error "3:'g' was not declared in this scope" }
   g(S());
   h(1);
 }
Index: testsuite/g++.dg/warn/Wshadow-5.C
===================================================================
--- testsuite/g++.dg/warn/Wshadow-5.C	(revision 236884)
+++ testsuite/g++.dg/warn/Wshadow-5.C	(working copy)
@@ -7,7 +7,7 @@ 
 int f (int n)
 {
     int bar (int n) { return n++; } // { dg-error "a function-definition is not allowed here" }
-    return bar (n); // { dg-error "was not declared in this scope" }
+    return bar (n); // { dg-error "12:'bar' was not declared in this scope" }
 }
 
 int g (int i)
Index: testsuite/g++.dg/warn/Wunused-8.C
===================================================================
--- testsuite/g++.dg/warn/Wunused-8.C	(revision 236884)
+++ testsuite/g++.dg/warn/Wunused-8.C	(working copy)
@@ -5,5 +5,5 @@  int main ()
 {
   // We should not see an "unused" warning about "whatever" on the
   // next line.
-  return whatever (); // { dg-error "declared" }
+  return whatever (); // { dg-error "10:'whatever' was not declared" }
 }
Index: testsuite/g++.old-deja/g++.bugs/900211_01.C
===================================================================
--- testsuite/g++.old-deja/g++.bugs/900211_01.C	(revision 236884)
+++ testsuite/g++.old-deja/g++.bugs/900211_01.C	(working copy)
@@ -10,7 +10,7 @@ 
 
 void global_function_0 ()
 {
-  global_function_1 ();		/* { dg-error "" } */
+  global_function_1 ();		/* { dg-error "3:'global_function_1' was not declared" } */
 }
 
 int main () { return 0; }
Index: testsuite/g++.old-deja/g++.jason/lineno5.C
===================================================================
--- testsuite/g++.old-deja/g++.jason/lineno5.C	(revision 236884)
+++ testsuite/g++.old-deja/g++.jason/lineno5.C	(working copy)
@@ -6,5 +6,5 @@  template <class T> class A;
 int main()
 {
   A<int> *p;
-  undef1();// { dg-error "" } 
+  undef1();// { dg-error "3:'undef1' was not declared" } 
 }
Index: testsuite/g++.old-deja/g++.jason/member.C
===================================================================
--- testsuite/g++.old-deja/g++.jason/member.C	(revision 236884)
+++ testsuite/g++.old-deja/g++.jason/member.C	(working copy)
@@ -5,7 +5,7 @@  struct Y
   struct X
     {
       int A;
-      int Y::X::* foo () { undef1(1); return &Y::X::A; }// { dg-error "" } foo().*
+      int Y::X::* foo () { undef1(1); return &Y::X::A; }// { dg-error "28:'undef1' was not declared" } foo().*
       int bar () { return A; }
     };
 };
@@ -12,24 +12,24 @@  struct Y
 
 int Y::X::* foo ()
 {
-  undef2(1);// { dg-error "" } foo().*
+  undef2(1);// { dg-error "3:'undef2' was not declared" } foo().*
   return &Y::X::A;
 }
 
 int Y::X::* (* foo2 ())()
 {
-  undef3(1);// { dg-error "" } foo().*
+  undef3(1);// { dg-error "3:'undef3' was not declared" } foo().*
   return foo;
 }
 
 int (Y::X::* bar2 ()) ()
 {
-  undef4(1);// { dg-error "" } foo\(\).*
+  undef4(1);// { dg-error "3:'undef4' was not declared" } foo\(\).*
   return Y::X::bar;// { dg-error "" } foo\(\).*
 }
 
 int Y::X::* (Y::X::* foo3 ())()
 {
-  undef5(1);// { dg-error "" } foo().*
+  undef5(1);// { dg-error "3:'undef5' was not declared" } foo().*
   return Y::X::foo;// { dg-error "" } foo().*
 }
Index: testsuite/g++.old-deja/g++.jason/report.C
===================================================================
--- testsuite/g++.old-deja/g++.jason/report.C	(revision 236884)
+++ testsuite/g++.old-deja/g++.jason/report.C	(working copy)
@@ -37,7 +37,7 @@  int foo (int a = (**bar) (s))
 
 int foo2 (int (*a)(int) = &foo)
 {
-   undef4 (1); // { dg-error "" } implicit declaration
+   undef4 (1); // { dg-error "4:'undef4' was not declared" } implicit declaration
   return 1;
 }
 
@@ -55,7 +55,7 @@  bar2 baz (X::Y y)	        // { dg-error "" } in th
   X::Y f;			// { dg-error "" } in this context
   bar2 wa [5];
   wa[0] = baz(f);
-  undef2 (1); // { dg-error "" } implicit declaration
+  undef2 (1); // { dg-error "3:'undef2' was not declared" } implicit declaration
 }				// { dg-warning "no return statement" }
 
 int ninny ()
@@ -70,5 +70,5 @@  int ninny ()
 
 int darg (char X::*p)
 {
-   undef3 (1); // { dg-error "" } implicit declaration
+   undef3 (1); // { dg-error "4:'undef3' was not declared" } implicit declaration
 }				// { dg-warning "no return statement" }
Index: testsuite/g++.old-deja/g++.jason/scoping12.C
===================================================================
--- testsuite/g++.old-deja/g++.jason/scoping12.C	(revision 236884)
+++ testsuite/g++.old-deja/g++.jason/scoping12.C	(working copy)
@@ -6,5 +6,5 @@  void f ()
   };
 }
 void h () {
-  g ();				// { dg-error "" } no g in scope
+  g ();				// { dg-error "3:'g' was not declared" } no g in scope
 }
Index: testsuite/g++.old-deja/g++.law/visibility20.C
===================================================================
--- testsuite/g++.old-deja/g++.law/visibility20.C	(revision 236884)
+++ testsuite/g++.old-deja/g++.law/visibility20.C	(working copy)
@@ -31,6 +31,6 @@  int main() {
     Base b;
     Derived d;
     d.noticeThisFunction(&b);
-    printf("gpptest run\n");// { dg-error "" } .*
+    printf("gpptest run\n");// { dg-error "5:'printf' was not declared" } .*
 }
 
Index: testsuite/g++.old-deja/g++.ns/koenig5.C
===================================================================
--- testsuite/g++.old-deja/g++.ns/koenig5.C	(revision 236884)
+++ testsuite/g++.old-deja/g++.ns/koenig5.C	(working copy)
@@ -14,6 +14,6 @@  void g()
   foo(new X);            // ok -- DR 218 says that we find the global
 			 // foo variable first, and therefore do not
 			 // perform argument-dependent lookup.
-  bar(new X);            // { dg-error "not declared" }
+  bar(new X);            // { dg-error "3:'bar' was not declared" }
   // { dg-message "suggested alternative" "suggested alternative" { target *-*-* } 17 }
 }
Index: testsuite/g++.old-deja/g++.other/static5.C
===================================================================
--- testsuite/g++.old-deja/g++.other/static5.C	(revision 236884)
+++ testsuite/g++.old-deja/g++.other/static5.C	(working copy)
@@ -9,7 +9,7 @@  struct S
 inline void f()
 {
   static S s;
-  atexit (0); // { dg-error "" } implicit declaration
+  atexit (0); // { dg-error "3:'atexit' was not declared" } implicit declaration
 }
 
 
Index: testsuite/g++.old-deja/g++.pt/overload2.C
===================================================================
--- testsuite/g++.old-deja/g++.pt/overload2.C	(revision 236884)
+++ testsuite/g++.old-deja/g++.pt/overload2.C	(working copy)
@@ -12,5 +12,5 @@  int
 main()
 {
 	C<char*>	c;
-	char*		p = Z(c.O); //{ dg-error "" } ambiguous c.O
+	char*		p = Z(c.O); //{ dg-error "13:'Z' was not declared" } ambiguous c.O
 }