From: Patrick Palka Date: Tue, 21 Apr 2020 14:56:57 +0000 (-0400) Subject: c++: Dependent conversion operator in concept [PR94597] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=08d6ec14e654292340ccc6aa5612bbd91d4d57e8;p=gcc.git c++: Dependent conversion operator in concept [PR94597] When building the parameter mapping for an atomic constraint, find_template_parameters does not spot the template parameter within the conversion-type-id of a dependent conversion operator, which later leads to an ICE during substitution when looking up the missing template argument for this unnoticed template parameter. gcc/cp/ChangeLog: PR c++/94597 * pt.c (any_template_parm_r) : New case. If this is a conversion operator, visit its TREE_TYPE. gcc/testsuite/ChangeLog: PR c++/94597 * g++.dg/cpp2a/concepts-conv2.C: New test. --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 81647d40b68..372fd08d1f9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-04-21 Patrick Palka + + PR c++/94597 + * pt.c (any_template_parm_r) : New case. If this + is a conversion operator, visit its TREE_TYPE. + 2020-04-21 Nathan Sidwell * pt.c (tsubst_copy_and_build) [POINTER_PLUS_EXPR]: Check for diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 6f74c278c23..0fc5b24841f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10529,6 +10529,12 @@ any_template_parm_r (tree t, void *data) } break; + case IDENTIFIER_NODE: + if (IDENTIFIER_CONV_OP_P (t)) + /* The conversion-type-id of a conversion operator may be dependent. */ + WALK_SUBTREE (TREE_TYPE (t)); + break; + default: break; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0de5a470ec6..1f3fb60d6d5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-04-21 Patrick Palka + + PR c++/94597 + * g++.dg/cpp2a/concepts-conv2.C: New test. + 2020-04-21 Duan bo PR target/94577 diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C b/gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C new file mode 100644 index 00000000000..821042f44ee --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-conv2.C @@ -0,0 +1,19 @@ +// PR c++/94597 +// { dg-do compile { target c++2a } } + +template concept d = requires(b e) { e.operator c(); }; + +template requires(d) bool equal(f, g); + +template struct i { + i(h); + operator h(); +}; + +static_assert( d, float>); +static_assert(!d, int>); + +bool fun() { + i a(2.0f); + return equal(a, 3.0f); +}