decl.c (duplicate_decls): Replace pairs of errors and permerrors with error + inform (permerror + inform...

/cp
2013-12-05  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (duplicate_decls): Replace pairs of errors and permerrors
	with error + inform (permerror + inform, respectively).

/testsuite
2013-12-05  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/cpp0x/constexpr-46336.C: Adjust expected messages.
	* g++.dg/cpp0x/defaulted2.C: Likewise.
	* g++.dg/cpp1y/auto-fn8.C: Likewise.
	* g++.dg/gomp/udr-3.C: Likewise.
	* g++.dg/lookup/extern-c-redecl5.C: Likewise.
	* g++.dg/lookup/linkage1.C: Likewise.
	* g++.dg/overload/new1.C: Likewise.
	* g++.dg/parse/friend5.C: Likewise.
	* g++.dg/parse/namespace-alias-1.C: Likewise.
	* g++.dg/parse/namespace10.C: Likewise.
	* g++.dg/parse/redef2.C: Likewise.
	* g++.dg/template/friend44.C: Likewise.
	* g++.old-deja/g++.brendan/crash42.C: Likewise.
	* g++.old-deja/g++.brendan/crash52.C: Likewise.
	* g++.old-deja/g++.brendan/crash55.C: Likewise.
	* g++.old-deja/g++.jason/overload21.C: Likewise.
	* g++.old-deja/g++.jason/overload5.C: Likewise.
	* g++.old-deja/g++.jason/redecl1.C: Likewise.
	* g++.old-deja/g++.law/arm8.C: Likewise.
	* g++.old-deja/g++.other/main1.C: Likewise.

From-SVN: r205697
This commit is contained in:
Paolo Carlini 2013-12-05 09:51:11 +00:00 committed by Paolo Carlini
parent fd9cf409e3
commit 23644e8ccb
23 changed files with 112 additions and 77 deletions

View file

@ -1,3 +1,8 @@
2013-12-05 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (duplicate_decls): Replace pairs of errors and permerrors
with error + inform (permerror + inform, respectively).
2013-12-04 Joseph Myers <joseph@codesourcery.com>
PR c/52023

View file

@ -1299,8 +1299,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
{
if (warning (OPT_Wattributes, "function %q+D redeclared as inline",
newdecl))
inform (input_location, "previous declaration of %q+D "
"with attribute noinline", olddecl);
inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration of %qD with attribute noinline",
olddecl);
}
else if (DECL_DECLARED_INLINE_P (olddecl)
&& DECL_UNINLINABLE (newdecl)
@ -1308,7 +1309,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
{
if (warning (OPT_Wattributes, "function %q+D redeclared with "
"attribute noinline", newdecl))
inform (input_location, "previous declaration of %q+D was inline",
inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration of %qD was inline",
olddecl);
}
}
@ -1343,11 +1345,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
warning (0, "library function %q#D redeclared as non-function %q#D",
olddecl, newdecl);
else
{
error ("declaration of %q#D", newdecl);
error ("conflicts with built-in declaration %q#D",
olddecl);
}
error ("declaration of %q#D conflicts with built-in "
"declaration %q#D", newdecl, olddecl);
return NULL_TREE;
}
else if (DECL_OMP_DECLARE_REDUCTION_P (olddecl))
@ -1355,8 +1354,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
gcc_assert (DECL_OMP_DECLARE_REDUCTION_P (newdecl));
error_at (DECL_SOURCE_LOCATION (newdecl),
"redeclaration of %<pragma omp declare reduction%>");
error_at (DECL_SOURCE_LOCATION (olddecl),
"previous %<pragma omp declare reduction%> declaration");
inform (DECL_SOURCE_LOCATION (olddecl),
"previous %<pragma omp declare reduction%> declaration");
return error_mark_node;
}
else if (!types_match)
@ -1407,11 +1406,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
/* A near match; override the builtin. */
if (TREE_PUBLIC (newdecl))
{
warning (0, "new declaration %q#D", newdecl);
warning (0, "ambiguates built-in declaration %q#D",
olddecl);
}
warning (0, "new declaration %q#D ambiguates built-in "
"declaration %q#D", newdecl, olddecl);
else
warning (OPT_Wshadow,
DECL_BUILT_IN (olddecl)
@ -1504,7 +1500,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
error ("%q#D redeclared as different kind of symbol", newdecl);
if (TREE_CODE (olddecl) == TREE_LIST)
olddecl = TREE_VALUE (olddecl);
inform (input_location, "previous declaration of %q+#D", olddecl);
inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration %q#D", olddecl);
return error_mark_node;
}
@ -1523,8 +1520,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
if (TREE_CODE (DECL_TEMPLATE_RESULT (olddecl)) == TYPE_DECL
|| TREE_CODE (DECL_TEMPLATE_RESULT (newdecl)) == TYPE_DECL)
{
error ("declaration of template %q#D", newdecl);
error ("conflicts with previous declaration %q+#D", olddecl);
error ("conflicting declaration of template %q#D", newdecl);
inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration %q#D", olddecl);
return error_mark_node;
}
else if (TREE_CODE (DECL_TEMPLATE_RESULT (olddecl)) == FUNCTION_DECL
@ -1538,8 +1536,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
&& same_type_p (TREE_TYPE (TREE_TYPE (newdecl)),
TREE_TYPE (TREE_TYPE (olddecl))))
{
error ("new declaration %q#D", newdecl);
error ("ambiguates old declaration %q+#D", olddecl);
error ("ambiguating new declaration %q#D", newdecl);
inform (DECL_SOURCE_LOCATION (olddecl),
"old declaration %q#D", olddecl);
}
return NULL_TREE;
}
@ -1547,9 +1546,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
{
if (DECL_EXTERN_C_P (newdecl) && DECL_EXTERN_C_P (olddecl))
{
error ("declaration of C function %q#D conflicts with",
error ("conflicting declaration of C function %q#D",
newdecl);
error ("previous declaration %q+#D here", olddecl);
inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration %q#D", olddecl);
return NULL_TREE;
}
/* For function versions, params and types match, but they
@ -1559,8 +1559,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
&& compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)),
TYPE_ARG_TYPES (TREE_TYPE (olddecl))))
{
error ("new declaration %q#D", newdecl);
error ("ambiguates old declaration %q+#D", olddecl);
error ("ambiguating new declaration of %q#D", newdecl);
inform (DECL_SOURCE_LOCATION (olddecl),
"old declaration %q#D", olddecl);
return error_mark_node;
}
else
@ -1569,8 +1570,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
else
{
error ("conflicting declaration %q#D", newdecl);
inform (input_location,
"%q+D has a previous declaration as %q#D", olddecl, olddecl);
inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration as %q#D", olddecl);
return error_mark_node;
}
}
@ -1622,8 +1623,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
A namespace-name defined at global scope shall not be
declared as the name of any other entity in any global scope
of the program. */
error ("declaration of namespace %qD conflicts with", newdecl);
error ("previous declaration of namespace %q+D here", olddecl);
error ("conflicting declaration of namespace %qD", newdecl);
inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration of namespace %qD here", olddecl);
return error_mark_node;
}
else
@ -1645,9 +1647,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
&& prototype_p (TREE_TYPE (newdecl)))
{
/* Prototype decl follows defn w/o prototype. */
warning_at (input_location, 0, "prototype for %q+#D", newdecl);
warning_at (DECL_SOURCE_LOCATION (olddecl), 0,
"follows non-prototype definition here");
warning_at (DECL_SOURCE_LOCATION (newdecl), 0,
"prototype specified for %q#D", newdecl);
inform (DECL_SOURCE_LOCATION (olddecl),
"previous non-prototype definition here");
}
else if (VAR_OR_FUNCTION_DECL_P (olddecl)
&& DECL_LANGUAGE (newdecl) != DECL_LANGUAGE (olddecl))
@ -1686,10 +1689,11 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
}
else
{
error ("previous declaration of %q+#D with %qL linkage",
olddecl, DECL_LANGUAGE (olddecl));
error ("conflicts with new declaration with %qL linkage",
DECL_LANGUAGE (newdecl));
error ("conflicting declaration of %q#D with %qL linkage",
newdecl, DECL_LANGUAGE (newdecl));
inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration with %qL linkage",
DECL_LANGUAGE (olddecl));
}
}
@ -1729,19 +1733,20 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
if (1 == simple_cst_equal (TREE_PURPOSE (t1),
TREE_PURPOSE (t2)))
{
permerror (input_location,
"default argument given for parameter %d "
"of %q#D", i, newdecl);
permerror (input_location,
"after previous specification in %q+#D",
olddecl);
if (permerror (input_location,
"default argument given for parameter "
"%d of %q#D", i, newdecl))
permerror (DECL_SOURCE_LOCATION (olddecl),
"previous specification in %q#D here",
olddecl);
}
else
{
error ("default argument given for parameter %d "
"of %q#D", i, newdecl);
error ("after previous specification in %q+#D",
olddecl);
inform (DECL_SOURCE_LOCATION (olddecl),
"previous specification in %q#D here",
olddecl);
}
}
}
@ -1805,7 +1810,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
if (warning (OPT_Wredundant_decls,
"redundant redeclaration of %qD in same scope",
newdecl))
inform (input_location, "previous declaration of %q+D", olddecl);
inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration of %qD", olddecl);
}
if (!(DECL_TEMPLATE_INSTANTIATION (olddecl)
@ -1814,7 +1820,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
if (DECL_DELETED_FN (newdecl))
{
error ("deleted definition of %qD", newdecl);
error ("after previous declaration %q+D", olddecl);
inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration of %qD", olddecl);
}
DECL_DELETED_FN (newdecl) |= DECL_DELETED_FN (olddecl);
}

View file

@ -1,3 +1,26 @@
2013-12-05 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/cpp0x/constexpr-46336.C: Adjust expected messages.
* g++.dg/cpp0x/defaulted2.C: Likewise.
* g++.dg/cpp1y/auto-fn8.C: Likewise.
* g++.dg/gomp/udr-3.C: Likewise.
* g++.dg/lookup/extern-c-redecl5.C: Likewise.
* g++.dg/lookup/linkage1.C: Likewise.
* g++.dg/overload/new1.C: Likewise.
* g++.dg/parse/friend5.C: Likewise.
* g++.dg/parse/namespace-alias-1.C: Likewise.
* g++.dg/parse/namespace10.C: Likewise.
* g++.dg/parse/redef2.C: Likewise.
* g++.dg/template/friend44.C: Likewise.
* g++.old-deja/g++.brendan/crash42.C: Likewise.
* g++.old-deja/g++.brendan/crash52.C: Likewise.
* g++.old-deja/g++.brendan/crash55.C: Likewise.
* g++.old-deja/g++.jason/overload21.C: Likewise.
* g++.old-deja/g++.jason/overload5.C: Likewise.
* g++.old-deja/g++.jason/redecl1.C: Likewise.
* g++.old-deja/g++.law/arm8.C: Likewise.
* g++.old-deja/g++.other/main1.C: Likewise.
2013-12-05 Richard Biener <rguenther@suse.de>
PR tree-optimization/56787

View file

@ -4,7 +4,7 @@
extern "C" {
enum A { };
inline constexpr A
f(A a, A b) // { dg-error "previous declaration" }
f(A a, A b) // { dg-message "previous declaration" }
{ return A(static_cast<int>(a) & static_cast<int>(b)); }
enum B { };
inline constexpr B

View file

@ -1,7 +1,7 @@
// Negative test for defaulted/deleted fns.
// { dg-options "-std=c++11" }
void f(); // { dg-error "previous" }
void f(); // { dg-message "previous" }
void f() = delete; // { dg-error "deleted" }
struct A

View file

@ -1,6 +1,6 @@
// { dg-options "-std=c++1y -pedantic-errors" }
auto f() { return 42; } // { dg-error "old declaration .auto" }
auto f() { return 42; } // { dg-message "old declaration .auto" }
auto f(); // OK
int f(); // { dg-error "new declaration" }

View file

@ -63,12 +63,12 @@ int y = f4 <S> ();
namespace N1
{
#pragma omp declare reduction (+: ::S: omp_out.s *= omp_in.s) // { dg-error "previous" }
#pragma omp declare reduction (+: ::S: omp_out.s *= omp_in.s) // { dg-message "previous" }
#pragma omp declare reduction (+: S: omp_out.s += omp_in.s) // { dg-error "redeclaration of" }
void
f5 ()
{
#pragma omp declare reduction (f5: S: omp_out.s *= omp_in.s) // { dg-error "previous" }
#pragma omp declare reduction (f5: S: omp_out.s *= omp_in.s) // { dg-message "previous" }
#pragma omp declare reduction (f5: ::S: omp_out.s += omp_in.s) // { dg-error "redeclaration of" }
}
}
@ -84,10 +84,10 @@ namespace N2
namespace N3
{
#pragma omp declare reduction (+: ::S: omp_out.s *= omp_in.s) // { dg-error "previous" }
#pragma omp declare reduction (+: ::S: omp_out.s *= omp_in.s) // { dg-message "previous" }
#pragma omp declare reduction (+: T: omp_out.t += omp_in.t)
#pragma omp declare reduction (+: S: omp_out.s += omp_in.s) // { dg-error "redeclaration of" }
#pragma omp declare reduction (n3: long: omp_out += omp_in) // { dg-error "previous" }
#pragma omp declare reduction (n3: long: omp_out += omp_in) // { dg-message "previous" }
#pragma omp declare reduction (n3: long int: omp_out += omp_in) // { dg-error "redeclaration of" }
#pragma omp declare reduction (n3: short unsigned: omp_out += omp_in)
#pragma omp declare reduction (n3: short int: omp_out += omp_in)
@ -95,9 +95,9 @@ namespace N3
f6 ()
{
#pragma omp declare reduction (f6: T: omp_out.t += omp_in.t)
#pragma omp declare reduction (f6: S: omp_out.s *= omp_in.s) // { dg-error "previous" }
#pragma omp declare reduction (f6: S: omp_out.s *= omp_in.s) // { dg-message "previous" }
#pragma omp declare reduction (f6: ::S: omp_out.s += omp_in.s) // { dg-error "redeclaration of" }
#pragma omp declare reduction (f6: long: omp_out += omp_in) // { dg-error "previous" }
#pragma omp declare reduction (f6: long: omp_out += omp_in) // { dg-message "previous" }
#pragma omp declare reduction (f6: long int: omp_out += omp_in) // { dg-error "redeclaration of" }
#pragma omp declare reduction (f6: short unsigned: omp_out += omp_in)
#pragma omp declare reduction (f6: short int: omp_out += omp_in)
@ -124,7 +124,7 @@ namespace N5
int
f7 ()
{
#pragma omp declare reduction (f7: T: omp_out.s *= omp_in.s) // { dg-error "previous" }
#pragma omp declare reduction (f7: T: omp_out.s *= omp_in.s) // { dg-message "previous" }
#pragma omp declare reduction (f7: T: omp_out.s += omp_in.s) // { dg-error "redeclaration of" }
return 0;
}
@ -145,9 +145,9 @@ namespace N6
f8 ()
{
#pragma omp declare reduction (f8: T: omp_out.t += omp_in.t)
#pragma omp declare reduction (f8: U: omp_out.s *= omp_in.s) // { dg-error "previous" }
#pragma omp declare reduction (f8: U: omp_out.s *= omp_in.s) // { dg-message "previous" }
#pragma omp declare reduction (f8: ::S: omp_out.s += omp_in.s) // { dg-error "redeclaration of" }
#pragma omp declare reduction (f8: long: omp_out += omp_in) // { dg-error "previous" }
#pragma omp declare reduction (f8: long: omp_out += omp_in) // { dg-message "previous" }
#pragma omp declare reduction (f8: long int: omp_out += omp_in) // { dg-error "redeclaration of" }
#pragma omp declare reduction (f8: short unsigned: omp_out += omp_in)
#pragma omp declare reduction (f8: short int: omp_out += omp_in)

View file

@ -6,11 +6,11 @@
class frok
{
int this_errno;
friend int fork (void); // { dg-error "previous declaration .*?C\\+\\+. linkage" }
friend int fork (void); // { dg-message "previous declaration .*?C\\+\\+. linkage" }
};
extern "C" int
fork (void) // { dg-error "conflicts with new declaration .*?C. linkage" }}
fork (void) // { dg-error "conflicting declaration .*?C. linkage" }}
{
frok grouped;
return grouped.this_errno;

View file

@ -1,4 +1,4 @@
// DR 563
extern int i; // { dg-error "linkage" }
extern int i; // { dg-message "linkage" }
extern "C" int i; // { dg-error "linkage" }

View file

@ -7,7 +7,7 @@ struct X{
};
void f(X *x = new X); // { dg-error "" }
void f(X *x = new X); // { dg-message "" }
void f(X *x = new X(4)); // { dg-error "" }

View file

@ -2,6 +2,6 @@
extern "C" struct A
{
friend void foo(int) {} // { dg-error "declaration" }
friend void foo(int) {} // { dg-message "declaration" }
friend void foo() {} // { dg-error "foo" "err" }
};

View file

@ -2,6 +2,6 @@
namespace N
{
namespace M = N; // { dg-error "previous declaration" }
namespace M = N; // { dg-message "previous declaration" }
namespace M {} // { dg-error "declaration of namespace" }
}

View file

@ -1,6 +1,6 @@
// PR c++/16529
namespace m {} // { dg-error "" }
namespace m {} // { dg-message "" }
namespace n {
namespace m {}

View file

@ -1,6 +1,6 @@
// { dg-do compile }
char * d [10]; // { dg-message "8: 'd' has a previous declaration as" }
char * d [10]; // { dg-message "8: previous declaration as" }
char e [15][10];
int (*f)();

View file

@ -3,7 +3,7 @@
template<int> struct A
{
friend int foo(); // { dg-error "14:new declaration" }
friend int foo(); // { dg-error "14:ambiguating new declaration" }
};
void foo() { A<0> a; } // { dg-error "6:ambiguates old declaration" }
void foo() { A<0> a; } // { dg-message "6:old declaration" }

View file

@ -1,6 +1,6 @@
// { dg-do assemble }
// GROUPS passed old-abort
int fn();// { dg-error "" } ambiguates.*
int fn();// { dg-message "" } ambiguates.*
int x;
int& fn() {// { dg-error "" } new decl.*
return x;}

View file

@ -5,9 +5,9 @@
class A {
public:
friend A f(A &a);// { dg-error "ambiguates" }
friend A f(A &a);// { dg-message "old declaration" }
};
A &f(A &a) {// { dg-error "new decl" }
A &f(A &a) {// { dg-error "new declaration" }
std::cout << "Blah\n";
} // { dg-warning "no return statement" }

View file

@ -1,6 +1,6 @@
// { dg-do compile }
// GROUPS passed old-abort
extern int f(int); // { dg-error "ambiguates" }
extern int f(int); // { dg-message "old declaration" }
int& f(int x) // { dg-error "new declaration" }
{

View file

@ -1,7 +1,7 @@
// { dg-do assemble }
struct X {
void f (int = 4, char = 'r'); // { dg-error "previous specification" }
void g (int = 4, char = 'r'); // { dg-error "previous specification" }
void g (int = 4, char = 'r'); // { dg-message "previous specification" }
};
void

View file

@ -1,5 +1,5 @@
// { dg-do assemble }
// Testcase for simple overloading resolution.
int foo (); // { dg-error "" }
int foo (); // { dg-message "" }
void foo (); // { dg-error "" } disallowed overload

View file

@ -3,7 +3,7 @@ class A
{
public:
A (const A& ccref);
friend A const re (const A& v1); // { dg-error "ambiguates" }
friend A const re (const A& v1); // { dg-message "old declaration" }
};
A // const

View file

@ -7,7 +7,7 @@
// Date: Tue, 16 Mar 93 12:05:24 +0100
struct K {
void f( int *p = 0); // { dg-error "" } previous specification
void f( int *p = 0); // { dg-message "" } previous specification
};
extern int * q;

View file

@ -1,12 +1,12 @@
// { dg-do compile }
int main() // { dg-error "previous declaration" }
int main() // { dg-message "previous declaration" }
{
return 0;
}
int main(int, const char**) // { dg-error "conflicts" }
int main(int, const char**) // { dg-error "conflicting" }
{
return 0;
}