c++: Instantiate less when evaluating __is_convertible
commitbe4b32b9ef69b86b662cb7511b48cd1048a55403
authorMarek Polacek <polacek@redhat.com>
Mon, 26 Sep 2022 14:21:38 +0000 (26 10:21 -0400)
committerMarek Polacek <polacek@redhat.com>
Mon, 26 Sep 2022 16:20:38 +0000 (26 12:20 -0400)
treeb931de83ee678a47a7085e09152a6bacdf93adc1
parent099a66498bf7a40764002793eba66c881a251b76
c++: Instantiate less when evaluating __is_convertible

Jon reported that evaluating __is_convertible in a test led to
instantiating something ill-formed and so we failed to compile the test.
__is_convertible doesn't and shouldn't need to instantiate so much, so
let's limit it with a cp_unevaluated guard.  Use a helper function to
implement both built-ins.

PR c++/106784

gcc/cp/ChangeLog:

* method.cc (is_convertible_helper): New.
(is_convertible): Use it.
(is_nothrow_convertible): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/ext/is_convertible3.C: New test.
* g++.dg/ext/is_nothrow_convertible3.C: New test.
gcc/cp/method.cc
gcc/testsuite/g++.dg/ext/is_convertible3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/is_nothrow_convertible3.C [new file with mode: 0644]