Commit 8e09cb8b by Paolo Carlini Committed by Paolo Carlini

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

/cp
2017-06-29  Paolo Carlini  <paolo.carlini@oracle.com>

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

/testsuite
2017-06-29  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.

From-SVN: r249820
parent 0395a464
2017-06-29 Paolo Carlini <paolo.carlini@oracle.com>
* class.c (add_method): Change pair of errors to error + inform.
(handle_using_decl): Likewise.
2017-06-29 Jason Merrill <jason@redhat.com> 2017-06-29 Jason Merrill <jason@redhat.com>
* constexpr.c, error.c, tree.c: Remove WITH_CLEANUP_EXPR handling. * constexpr.c, error.c, tree.c: Remove WITH_CLEANUP_EXPR handling.
......
...@@ -1217,9 +1217,10 @@ add_method (tree type, tree method, bool via_using) ...@@ -1217,9 +1217,10 @@ add_method (tree type, tree method, bool via_using)
continue; continue;
} }
error_at (DECL_SOURCE_LOCATION (method), error_at (DECL_SOURCE_LOCATION (method),
"%q#D", method); "%q#D conflicts with version inherited from %qT",
error_at (DECL_SOURCE_LOCATION (fn), method, basef);
"conflicts with version inherited from %qT", inform (DECL_SOURCE_LOCATION (fn),
"version inherited from %qT declared here",
basef); basef);
} }
/* Otherwise defer to the other function. */ /* Otherwise defer to the other function. */
...@@ -1238,8 +1239,10 @@ add_method (tree type, tree method, bool via_using) ...@@ -1238,8 +1239,10 @@ add_method (tree type, tree method, bool via_using)
} }
else else
{ {
error ("%q+#D cannot be overloaded", method); error_at (DECL_SOURCE_LOCATION (method),
error ("with %q+#D", fn); "%q#D cannot be overloaded with %q#D", method, fn);
inform (DECL_SOURCE_LOCATION (fn),
"previous declaration %q#D", fn);
return false; return false;
} }
} }
...@@ -1371,16 +1374,21 @@ handle_using_decl (tree using_decl, tree t) ...@@ -1371,16 +1374,21 @@ handle_using_decl (tree using_decl, tree t)
the same name already present in the current class. */; the same name already present in the current class. */;
else else
{ {
error ("%q+D invalid in %q#T", using_decl, t); error_at (DECL_SOURCE_LOCATION (using_decl), "%qD invalid in %q#T "
error (" because of local method %q+#D with same name", "because of local method %q#D with same name",
old_value); using_decl, t, old_value);
inform (DECL_SOURCE_LOCATION (old_value),
"local method %q#D declared here", old_value);
return; return;
} }
} }
else if (!DECL_ARTIFICIAL (old_value)) else if (!DECL_ARTIFICIAL (old_value))
{ {
error ("%q+D invalid in %q#T", using_decl, t); error_at (DECL_SOURCE_LOCATION (using_decl), "%qD invalid in %q#T "
error (" because of local member %q+#D with same name", old_value); "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; return;
} }
......
2017-06-29 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.
2017-06-29 Cesar Philippidis <cesar@codesourcery.com> 2017-06-29 Cesar Philippidis <cesar@codesourcery.com>
PR fortran/77765 PR fortran/77765
......
...@@ -8,7 +8,7 @@ struct B2 { ...@@ -8,7 +8,7 @@ struct B2 {
B2(int); B2(int);
}; };
struct D1 : B1, B2 { struct D1 : B1, B2 {
using B1::B1; // { dg-error "inherited" } using B1::B1; // { dg-message "declared" }
using B2::B2; // { dg-error "inherited" } using B2::B2; // { dg-error "inherited" }
}; // ill-formed: attempts to declare D1(int) twice }; // ill-formed: attempts to declare D1(int) twice
struct D2 : B1, B2 { struct D2 : B1, B2 {
......
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
template<int N> struct B { }; template<int N> struct B { };
template<typename... T> struct A 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" } B<42> f(); // { dg-error "cannot be overloaded" }
}; };
...@@ -77,7 +77,7 @@ namespace N2 ...@@ -77,7 +77,7 @@ namespace N2
{ {
struct U 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" } #pragma omp declare reduction (bar: S: omp_out.s += omp_in.s) // { dg-error "cannot be overloaded" }
}; };
} }
...@@ -109,9 +109,9 @@ namespace N4 ...@@ -109,9 +109,9 @@ namespace N4
struct U struct U
{ {
#pragma omp declare reduction (bar: T: omp_out.t += omp_in.t) #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: 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: 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 unsigned: omp_out += omp_in)
#pragma omp declare reduction (bar: short int: omp_out += omp_in) #pragma omp declare reduction (bar: short int: omp_out += omp_in)
...@@ -132,7 +132,7 @@ namespace N5 ...@@ -132,7 +132,7 @@ namespace N5
template <typename T> template <typename T>
struct U 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" } #pragma omp declare reduction (bar: T: omp_out.s += omp_in.s) // { dg-error "cannot be overloaded" }
}; };
U<S> u; U<S> u;
...@@ -159,9 +159,9 @@ namespace N6 ...@@ -159,9 +159,9 @@ namespace N6
{ {
typedef V V2; typedef V V2;
#pragma omp declare reduction (bar: T: omp_out.t += omp_in.t) #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: 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: 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 unsigned: omp_out += omp_in)
#pragma omp declare reduction (bar: short int: omp_out += omp_in) #pragma omp declare reduction (bar: short int: omp_out += omp_in)
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
struct S struct S
{ {
void f () {} // { dg-error "with" } void f () {} // { dg-message "previous" }
int f () { return 0; } // { dg-error "overloaded" } int f () { return 0; } // { dg-error "overloaded" }
}; };
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
struct A struct A
{ {
void foo(); // { dg-error "with" } void foo(); // { dg-message "previous" }
virtual void foo(); // { dg-error "cannot be overloaded" } virtual void foo(); // { dg-error "cannot be overloaded" }
}; };
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
template<int> struct A template<int> struct A
{ {
~A() {} // { dg-error "with" } ~A() {} // { dg-message "previous" }
~A() {} // { dg-error "cannot be overloaded" } ~A() {} // { dg-error "cannot be overloaded" }
}; };
...@@ -31,7 +31,7 @@ class C ...@@ -31,7 +31,7 @@ class C
class D class D
{ {
public: public:
int foo2() {return b;} // { dg-error "with" } int foo2() {return b;} // { dg-message "previous" }
int foo2() {return b;} // { dg-error "overloaded" } int foo2() {return b;} // { dg-error "overloaded" }
int b; int b;
}; };
...@@ -39,7 +39,7 @@ public: ...@@ -39,7 +39,7 @@ public:
class E class E
{ {
public: public:
int foo2(); // { dg-error "with" } int foo2(); // { dg-message "previous" }
int foo2(); // { dg-error "overloaded" } int foo2(); // { dg-error "overloaded" }
int b; int b;
}; };
......
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
class X { class X {
public: public:
int foo(); // { dg-error "with" } int foo(); // { dg-message "previous" }
static int foo(); // error: redeclaration// { dg-error "overloaded" } .* static int foo(); // error: redeclaration// { dg-error "overloaded" } .*
}; };
class Y { class Y {
public: public:
static int foo(); // { dg-error "with" } static int foo(); // { dg-message "previous" }
int foo(); // error: redeclaration// { dg-error "overloaded" } .* int foo(); // error: redeclaration// { dg-error "overloaded" } .*
}; };
// { dg-do assemble } // { dg-do assemble }
struct S { struct S {
S(int); // { dg-error "with" } S(int); // { dg-message "previous" }
S(int); // { dg-error "overloaded" } already declared S(int); // { dg-error "overloaded" } already declared
~S();// { dg-error "with" } ~S();// { dg-message "previous" }
~S(); // { dg-error "overloaded" } already declared ~S(); // { dg-error "overloaded" } already declared
}; };
// { dg-do assemble } // { dg-do assemble }
int main() { int main() {
struct A { struct A {
void f(); // { dg-error "with" } already declared void f(); // { dg-message "previous" } already declared
void f(); // { dg-error "overloaded" } already declared void f(); // { dg-error "overloaded" } already declared
}; };
} }
...@@ -23,7 +23,7 @@ template struct B<int>; ...@@ -23,7 +23,7 @@ template struct B<int>;
struct C struct C
{ {
template <class U> template <class U>
void f() {} // { dg-error "with" } redeclaration void f() {} // { dg-message "previous" } redeclaration
template <class U> template <class U>
void f() {} // { dg-error "overloaded" } redeclaration void f() {} // { dg-error "overloaded" } redeclaration
...@@ -42,7 +42,7 @@ template struct D<int, double>; ...@@ -42,7 +42,7 @@ template struct D<int, double>;
template <class T, class U> template <class T, class U>
struct D2 struct D2
{ {
void f(T); // { dg-error "with" } redeclaration void f(T); // { dg-message "previous" } redeclaration
void f(U); // { dg-error "overloaded" } redeclaration void f(U); // { dg-error "overloaded" } redeclaration
}; };
...@@ -50,7 +50,7 @@ template struct D2<int, int>; ...@@ -50,7 +50,7 @@ template struct D2<int, int>;
struct E struct E
{ {
void f(); // { dg-error "with" } redeclaration void f(); // { dg-message "previous" } redeclaration
void f(); // { dg-error "overloaded" } redeclaration void f(); // { dg-error "overloaded" } redeclaration
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment