c++: SFINAE for invalid delete-expression [PR79706]
authorPatrick Palka <ppalka@redhat.com>
Wed, 13 May 2020 20:27:45 +0000 (16:27 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 13 May 2020 20:40:23 +0000 (16:40 -0400)
commit4924293a62ee797310dd448e545118afd5aebb3f
tree978ab0a2c7a24bb434902c69a12988d2b0187167
parent7e52f8b1e03776575b92574252d9b6bbed9f1af4
c++: SFINAE for invalid delete-expression [PR79706]

This fixes SFINAE when substitution yields an invalid delete-expression
due to the pertinent deallocation function being marked deleted or
otherwise inaccessible.

We need to check for an erroneous result from build_op_delete_call and
exit early in that case, so that we don't build a COND_EXPR around the
erroneous result which finish_decltype_type would then quietly accept.

gcc/cp/ChangeLog:

PR c++/79706
* init.c (build_vec_delete_1): Just return error_mark_node if
deallocate_expr is error_mark_node.
(build_delete): Just return error_mark_node if do_delete is
error_mark_node.

gcc/testsuite/ChangeLog:

PR c++/79706
* g++.dg/template/sfinae30.C: New test.
gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/sfinae30.C [new file with mode: 0644]