diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d2fc1c1d4a3..0ed15f53596 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2160,11 +2160,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) if (DECL_DELETED_FN (newdecl)) { auto_diagnostic_group d; - pedwarn (newdecl_loc, OPT_Wpedantic, - "deleted definition of %qD is not first declaration", - newdecl); - inform (olddecl_loc, - "previous declaration of %qD", olddecl); + if (pedwarn (newdecl_loc, OPT_Wpedantic, "deleted definition of " + "%qD is not first declaration", newdecl)) + inform (olddecl_loc, + "previous declaration of %qD", olddecl); } DECL_DELETED_FN (newdecl) |= DECL_DELETED_FN (olddecl); } diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted15.C b/gcc/testsuite/g++.dg/cpp0x/deleted15.C new file mode 100644 index 00000000000..ab1893d7e29 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/deleted15.C @@ -0,0 +1,6 @@ +// PR c++/101106 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +int f(); // { dg-bogus "previous declaration" } +int f() = delete;