An explicitly deleted function must be deleted on its first declaration. We
were diagnosing this error only with -Wpedantic, but always giving the
"previous declaration" note. This patch removes the -Wpedantic dependency
and also makes the note depend on the previous diagnostic.
PR c++/101106
gcc/cp/ChangeLog:
* decl.c (duplicate_decls): Make 'deleted after first declaration'
pedwarn on by default.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/deleted15.C: New test.
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, 0, "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);
}
--- /dev/null
+// PR c++/101106
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+int f();
+int f() = delete; // { dg-message "not first declaration" }