aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-06-17 15:31:15 -0400
committerJason Merrill <jason@redhat.com>2021-06-17 15:48:07 -0400
commit331e20a69be0d9e7d448580945945d4c7a1e3c0a (patch)
tree4692abc579ecd8c252d4b637a323b9a1a85cfe20 /gcc
parent58e3b17f4c42d050a1768b025712e6d18bcb76ae (diff)
downloadgcc-331e20a69be0d9e7d448580945945d4c7a1e3c0a.zip
gcc-331e20a69be0d9e7d448580945945d4c7a1e3c0a.tar.gz
gcc-331e20a69be0d9e7d448580945945d4c7a1e3c0a.tar.bz2
c++: deleted after first declaration [PR101106]
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/decl.c9
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/deleted15.C6
2 files changed, 10 insertions, 5 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 02772e9..66bcc4b 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2170,11 +2170,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, 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);
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted15.C b/gcc/testsuite/g++.dg/cpp0x/deleted15.C
new file mode 100644
index 0000000..06d2171
--- /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();
+int f() = delete; // { dg-message "not first declaration" }