diff options
author | Patrick Palka <ppalka@redhat.com> | 2021-05-26 08:35:31 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2021-05-26 08:35:31 -0400 |
commit | b4329e3dd6fb7c78948fcf9d2f5b9d873deec284 (patch) | |
tree | d00562e26db85a44f3d94e1eee696e92b47d3c63 /gcc/function.h | |
parent | 95d67762171f83277a5700b270c0d1e2756f83f4 (diff) | |
download | gcc-b4329e3dd6fb7c78948fcf9d2f5b9d873deec284.zip gcc-b4329e3dd6fb7c78948fcf9d2f5b9d873deec284.tar.gz gcc-b4329e3dd6fb7c78948fcf9d2f5b9d873deec284.tar.bz2 |
c++: Fix reference NTTP binding to noexcept fn [PR97420]
Here, in C++17 mode, convert_nontype_argument_function is rejecting
binding a non-noexcept function reference template parameter to a
noexcept function (encoded as the template argument '*(int (&) (int)) &f').
The first roadblock to making this work is that the argument is wrapped
an an implicit INDIRECT_REF, so we need to unwrap it before calling
strip_fnptr_conv.
The second roadblock is that the NOP_EXPR cast converts from a function
pointer type to a reference type while simultaneously removing the
noexcept qualification, and fnptr_conv_p doesn't consider this cast to
be a function pointer conversion. This patch fixes this by making
fnptr_conv_p treat REFERENCE_TYPEs and POINTER_TYPEs interchangeably.
Finally, in passing, this patch also simplifies noexcept_conv_p by
removing a bunch of redundant checks already performed by its only
caller fnptr_conv_p.
PR c++/97420
gcc/cp/ChangeLog:
* cvt.c (noexcept_conv_p): Remove redundant checks and simplify.
(fnptr_conv_p): Don't call non_reference. Use INDIRECT_TYPE_P
instead of TYPE_PTR_P.
* pt.c (convert_nontype_argument_function): Look through
implicit INDIRECT_REFs before calling strip_fnptr_conv.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/noexcept68.C: New test.
Diffstat (limited to 'gcc/function.h')
0 files changed, 0 insertions, 0 deletions