public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] Replace a few more error + error with error + inform
@ 2017-05-19 16:15 Paolo Carlini
  2017-06-29  8:56 ` Paolo Carlini
  2017-06-29 21:46 ` Jason Merrill
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Carlini @ 2017-05-19 16:15 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 538 bytes --]

Hi,

while looking into some bugs (eg, c++/71464) I noticed a few more of 
those consecutive errors, which I propose to adjust per the below 
patchlet. The second case in add_method is a bit tricky because in 
principle we'd really like to be more specific (eg, clang talks about 
constructors which cannot be redeclared, member functions which cannot 
be redeclared and many more) and avoid verbose diagnostic, but in the 
below I only try to avoid emitting error + error... Tested x86_64-linux.

Thanks, Paolo.

/////////////////////



[-- Attachment #2: CL_error_inform_3 --]
[-- Type: text/plain, Size: 722 bytes --]

/cp
2017-05-19  Paolo Carlini  <paolo.carlini@oracle.com>

	* class.c (add_method): Change pair of errors to error + inform.
	(handle_using_decl): Likewise.

/testsuite
2017-05-19  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/cpp0x/inh-ctor3.C: Adjust for dg-message vs dg-error.
	* g++.dg/diagnostic/variadic1.C: Likewise.
	* g++.dg/gomp/udr-3.C: Likewise.
	* g++.dg/overload/error1.C: Likewise.
	* g++.dg/overload/error2.C: Likewise.
	* g++.dg/template/duplicate1.C: Likewise.
	* g++.old-deja/g++.benjamin/warn02.C: Likewise.
	* g++.old-deja/g++.brendan/arm2.C: Likewise.
	* g++.old-deja/g++.other/redecl2.C: Likewise.
	* g++.old-deja/g++.other/redecl4.C: Likewise.
	* g++.old-deja/g++.pt/memtemp78.C: Likewise.

[-- Attachment #3: patch_error_inform_3 --]
[-- Type: text/plain, Size: 10393 bytes --]

Index: cp/class.c
===================================================================
--- cp/class.c	(revision 248245)
+++ cp/class.c	(working copy)
@@ -1212,10 +1212,11 @@ add_method (tree type, tree method, bool via_using
 			continue;
 		    }
 		  error_at (DECL_SOURCE_LOCATION (method),
-			    "%q#D", method);
-		  error_at (DECL_SOURCE_LOCATION (fn),
-			    "conflicts with version inherited from %qT",
-			    basef);
+			    "%q#D conflicts with version inherited from %qT",
+			    method, basef);
+		  inform (DECL_SOURCE_LOCATION (fn),
+			  "version inherited from %qT declared here",
+			  basef);
 		}
 	      /* Otherwise defer to the other function.  */
 	      return false;
@@ -1233,8 +1234,10 @@ add_method (tree type, tree method, bool via_using
 	    }
 	  else
 	    {
-	      error ("%q+#D cannot be overloaded", method);
-	      error ("with %q+#D", fn);
+	      error_at (DECL_SOURCE_LOCATION (method),
+			"%q#D cannot be overloaded with %q#D", method, fn);
+	      inform (DECL_SOURCE_LOCATION (fn),
+		      "previous declaration %q#D", fn);
 	      return false;
 	    }
 	}
@@ -1366,16 +1369,21 @@ handle_using_decl (tree using_decl, tree t)
 	   the same name already present in the current class.  */;
       else
 	{
-	  error ("%q+D invalid in %q#T", using_decl, t);
-	  error ("  because of local method %q+#D with same name",
-		 old_value);
+	  error_at (DECL_SOURCE_LOCATION (using_decl), "%qD invalid in %q#T "
+		    "because of local method %q#D with same name",
+		    using_decl, t, old_value);
+	  inform (DECL_SOURCE_LOCATION (old_value),
+		  "local method %q#D declared here", old_value);
 	  return;
 	}
     }
   else if (!DECL_ARTIFICIAL (old_value))
     {
-      error ("%q+D invalid in %q#T", using_decl, t);
-      error ("  because of local member %q+#D with same name", old_value);
+      error_at (DECL_SOURCE_LOCATION (using_decl), "%qD invalid in %q#T "
+		"because of local member %q#D with same name",
+		using_decl, t, old_value);
+      inform (DECL_SOURCE_LOCATION (old_value),
+	      "local member %q#D declared here", old_value);
       return;
     }
 
Index: testsuite/g++.dg/cpp0x/inh-ctor3.C
===================================================================
--- testsuite/g++.dg/cpp0x/inh-ctor3.C	(revision 248244)
+++ testsuite/g++.dg/cpp0x/inh-ctor3.C	(working copy)
@@ -8,7 +8,7 @@ struct B2 {
   B2(int);
 };
 struct D1 : B1, B2 {
-  using B1::B1;			// { dg-error "inherited" }
+  using B1::B1;			// { dg-message "declared" }
   using B2::B2;			// { dg-error "inherited" }
 };			   // ill-formed: attempts to declare D1(int) twice
 struct D2 : B1, B2 {
Index: testsuite/g++.dg/diagnostic/variadic1.C
===================================================================
--- testsuite/g++.dg/diagnostic/variadic1.C	(revision 248244)
+++ testsuite/g++.dg/diagnostic/variadic1.C	(working copy)
@@ -4,6 +4,6 @@
 template<int N> struct B { };
 template<typename... T> struct A
 {
-  B<sizeof...(T)> f();		// { dg-error "sizeof\\.\\.\\." }
+  B<sizeof...(T)> f();		// { dg-message "sizeof\\.\\.\\." }
   B<42> f();			// { dg-error "cannot be overloaded" }
 };
Index: testsuite/g++.dg/gomp/udr-3.C
===================================================================
--- testsuite/g++.dg/gomp/udr-3.C	(revision 248244)
+++ testsuite/g++.dg/gomp/udr-3.C	(working copy)
@@ -77,7 +77,7 @@ namespace N2
 {
   struct U
   {
-    #pragma omp declare reduction (bar: S: omp_out.s *= omp_in.s)	// { dg-error "with" }
+    #pragma omp declare reduction (bar: S: omp_out.s *= omp_in.s)	// { dg-message "previous" }
     #pragma omp declare reduction (bar: S: omp_out.s += omp_in.s)	// { dg-error "cannot be overloaded" }
   };
 }
@@ -109,9 +109,9 @@ namespace N4
   struct U
   {
     #pragma omp declare reduction (bar: T: omp_out.t += omp_in.t)
-    #pragma omp declare reduction (bar: S: omp_out.s *= omp_in.s)	// { dg-error "with" }
+    #pragma omp declare reduction (bar: S: omp_out.s *= omp_in.s)	// { dg-message "previous" }
     #pragma omp declare reduction (bar: S: omp_out.s += omp_in.s)	// { dg-error "cannot be overloaded" }
-    #pragma omp declare reduction (bar: long: omp_out += omp_in)	// { dg-error "with" }
+    #pragma omp declare reduction (bar: long: omp_out += omp_in)	// { dg-message "previous" }
     #pragma omp declare reduction (bar: long int: omp_out += omp_in)	// { dg-error "cannot be overloaded" }
     #pragma omp declare reduction (bar: short unsigned: omp_out += omp_in)
     #pragma omp declare reduction (bar: short int: omp_out += omp_in)
@@ -132,7 +132,7 @@ namespace N5
   template <typename T>
   struct U
   {
-    #pragma omp declare reduction (bar: T: omp_out.s *= omp_in.s)	// { dg-error "with" }
+    #pragma omp declare reduction (bar: T: omp_out.s *= omp_in.s)	// { dg-message "previous" }
     #pragma omp declare reduction (bar: T: omp_out.s += omp_in.s)	// { dg-error "cannot be overloaded" }
   };
   U<S> u;
@@ -159,9 +159,9 @@ namespace N6
   {
     typedef V V2;
     #pragma omp declare reduction (bar: T: omp_out.t += omp_in.t)
-    #pragma omp declare reduction (bar: V: omp_out.s *= omp_in.s)	// { dg-error "with" }
+    #pragma omp declare reduction (bar: V: omp_out.s *= omp_in.s)	// { dg-message "previous" }
     #pragma omp declare reduction (bar: V2: omp_out.s += omp_in.s)	// { dg-error "cannot be overloaded" }
-    #pragma omp declare reduction (bar: long: omp_out += omp_in)	// { dg-error "with" }
+    #pragma omp declare reduction (bar: long: omp_out += omp_in)	// { dg-message "previous" }
     #pragma omp declare reduction (bar: long int: omp_out += omp_in)	// { dg-error "cannot be overloaded" }
     #pragma omp declare reduction (bar: short unsigned: omp_out += omp_in)
     #pragma omp declare reduction (bar: short int: omp_out += omp_in)
Index: testsuite/g++.dg/overload/error1.C
===================================================================
--- testsuite/g++.dg/overload/error1.C	(revision 248244)
+++ testsuite/g++.dg/overload/error1.C	(working copy)
@@ -2,6 +2,6 @@
 
 struct S
 {
-  void f () {} // { dg-error "with" }
+  void f () {} // { dg-message "previous" }
   int f () { return 0; } // { dg-error "overloaded" }
 };
Index: testsuite/g++.dg/overload/error2.C
===================================================================
--- testsuite/g++.dg/overload/error2.C	(revision 248244)
+++ testsuite/g++.dg/overload/error2.C	(working copy)
@@ -6,6 +6,6 @@
 
 struct A
 {
-  void foo();  // { dg-error "with" }
+  void foo();  // { dg-message "previous" }
   virtual void foo();  // { dg-error "cannot be overloaded" }
 };
Index: testsuite/g++.dg/template/duplicate1.C
===================================================================
--- testsuite/g++.dg/template/duplicate1.C	(revision 248244)
+++ testsuite/g++.dg/template/duplicate1.C	(working copy)
@@ -2,6 +2,6 @@
 
 template<int> struct A
 {
-  ~A() {}	// { dg-error "with" }
+  ~A() {}	// { dg-message "previous" }
   ~A() {}	// { dg-error "cannot be overloaded" }
 };
Index: testsuite/g++.old-deja/g++.benjamin/warn02.C
===================================================================
--- testsuite/g++.old-deja/g++.benjamin/warn02.C	(revision 248244)
+++ testsuite/g++.old-deja/g++.benjamin/warn02.C	(working copy)
@@ -31,7 +31,7 @@ class C
 class D
 {
 public:
-  int foo2() {return b;}  // { dg-error "with" } 
+  int foo2() {return b;}  // { dg-message "previous" } 
   int foo2() {return b;}  // { dg-error "overloaded" } 
   int b;
 };
@@ -39,7 +39,7 @@ class D
 class E
 {
 public:
-  int foo2(); // { dg-error "with" } 
+  int foo2(); // { dg-message "previous" } 
   int foo2(); // { dg-error "overloaded" } 
   int b;
 };
Index: testsuite/g++.old-deja/g++.brendan/arm2.C
===================================================================
--- testsuite/g++.old-deja/g++.brendan/arm2.C	(revision 248244)
+++ testsuite/g++.old-deja/g++.brendan/arm2.C	(working copy)
@@ -8,12 +8,12 @@
 
 class X {
 public:
-  int foo();            // { dg-error "with" }
+  int foo();            // { dg-message "previous" }
   static int foo();	// error: redeclaration// { dg-error "overloaded" } .*
 };
 
 class Y {
 public:
-   static int foo();    // { dg-error "with" }
+   static int foo();    // { dg-message "previous" }
   int foo();		// error: redeclaration// { dg-error "overloaded" } .*
 };
Index: testsuite/g++.old-deja/g++.other/redecl2.C
===================================================================
--- testsuite/g++.old-deja/g++.other/redecl2.C	(revision 248244)
+++ testsuite/g++.old-deja/g++.other/redecl2.C	(working copy)
@@ -1,9 +1,9 @@
 // { dg-do assemble  }
 
 struct S {
-  S(int); // { dg-error "with" }
+  S(int); // { dg-message "previous" }
   S(int); // { dg-error "overloaded" } already declared
 
-  ~S();// { dg-error "with" }
+  ~S();// { dg-message "previous" }
   ~S(); // { dg-error "overloaded" } already declared
 };
Index: testsuite/g++.old-deja/g++.other/redecl4.C
===================================================================
--- testsuite/g++.old-deja/g++.other/redecl4.C	(revision 248244)
+++ testsuite/g++.old-deja/g++.other/redecl4.C	(working copy)
@@ -1,7 +1,7 @@
 // { dg-do assemble  }
 int main() {
   struct A {
-    void f();			// { dg-error "with" } already declared
+    void f();			// { dg-message "previous" } already declared
     void f();			// { dg-error "overloaded" } already declared
   };
 }
Index: testsuite/g++.old-deja/g++.pt/memtemp78.C
===================================================================
--- testsuite/g++.old-deja/g++.pt/memtemp78.C	(revision 248244)
+++ testsuite/g++.old-deja/g++.pt/memtemp78.C	(working copy)
@@ -23,7 +23,7 @@ template struct B<int>;
 struct C 
 {
   template <class U>
-  void f() {}  // { dg-error "with" } redeclaration
+  void f() {}  // { dg-message "previous" } redeclaration
 
   template <class U>
   void f() {}  // { dg-error "overloaded" } redeclaration
@@ -42,7 +42,7 @@ template struct D<int, double>;
 template <class T, class U>
 struct D2
 {
-  void f(T); // { dg-error "with" } redeclaration 
+  void f(T); // { dg-message "previous" } redeclaration 
   void f(U); // { dg-error "overloaded" } redeclaration 
 };
 
@@ -50,7 +50,7 @@ template struct D2<int, int>;
 
 struct E
 {
-  void f();  // { dg-error "with" } redeclaration
+  void f();  // { dg-message "previous" } redeclaration
   void f(); // { dg-error "overloaded" } redeclaration
 };
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-29 21:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-19 16:15 [C++ Patch] Replace a few more error + error with error + inform Paolo Carlini
2017-06-29  8:56 ` Paolo Carlini
2017-06-29 21:46 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).