]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: deleted fn and noexcept inst [PR101532, PR104225]
authorPatrick Palka <ppalka@redhat.com>
Tue, 25 Jan 2022 20:04:49 +0000 (15:04 -0500)
committerPatrick Palka <ppalka@redhat.com>
Tue, 12 Apr 2022 23:31:48 +0000 (19:31 -0400)
commit1429db66619d2b801ac0b586b5eed74ab54a35b0
treeeb047e3e8061e5ba82cc21a18e7f99e37a4e314b
parent051d304ce8e2173bd0cb721ed91d4a1fefa61d87
c++: deleted fn and noexcept inst [PR101532, PR104225]

Here when attempting to use B's implicitly deleted default constructor,
mark_used rightfully returns false, but for the wrong reason: it
tries to instantiate the synthesized noexcept specifier which then only
silently fails because get_defaulted_eh_spec suppresses diagnostics
for deleted functions.  This lack of diagnostics causes us to crash on
the first testcase below (thanks to the assert in finish_expr_stmt), and
silently accept the second testcase.

To fix this, this patch makes mark_used avoid attempting to instantiate
the noexcept specifier of a deleted function, so that we'll instead
directly reject (and diagnose) the function due to its deletedness.

PR c++/101532
PR c++/104225

gcc/cp/ChangeLog:

* decl2.c (mark_used): Don't consider maybe_instantiate_noexcept
on a deleted function.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/nsdmi-template21.C: New test.
* g++.dg/cpp0x/nsdmi-template21a.C: New test.

(cherry picked from commit bc90dd0ecf02e11d47d1af7f627e2e2acaa40106)
gcc/cp/decl2.c
gcc/testsuite/g++.dg/cpp0x/nsdmi-template21.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/nsdmi-template21a.C [new file with mode: 0644]