* [C++ PATCH] PR60531 - Wrong error about unresolved overloaded function
@ 2019-04-13 11:54 Harald van Dijk
2019-04-26 20:31 ` [C++ PATCH, PING] " Harald van Dijk
0 siblings, 1 reply; 5+ messages in thread
From: Harald van Dijk @ 2019-04-13 11:54 UTC (permalink / raw)
To: gcc-patches
Hi,
For PR60531, GCC wrongly rejects function templates with explicitly
specified template arguments as overloaded. They are resolved by
resolve_nondeduced_context, which is normally called by
cp_default_conversion through decay_conversion, but the latter have
extra effects making them unusable here. Calling the former directly
does work.
Bootstrapped on x86_64-pc-linux-gnu on top of r270264 with
--enable-languages=all; make check shows no regressions.
Does this look okay?
This is my first code contribution to GCC, please let me know if
anything is missing. I have not signed any copyright disclaimer or
copyright assignment; <Contributing to GCC> says that is not necessary
for small changes, which I trust this is. If it is needed after all,
please let me know what specifically will be required.
Cheers,
Harald van Dijk
PR c++/60531
* typeck.c (cp_build_binary_op): See if overload can be resolved.
(cp_build_unary_op): Ditto.
* g++.dg/template/operator15.C: New test.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 03b14024738..e1ffe88ce2c 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -4384,10 +4384,6 @@ cp_build_binary_op (const op_location_t &location,
/* True if both operands have arithmetic type. */
bool arithmetic_types_p;
- /* Apply default conversions. */
- op0 = orig_op0;
- op1 = orig_op1;
-
/* Remember whether we're doing / or %. */
bool doing_div_or_mod = false;
@@ -4397,6 +4393,10 @@ cp_build_binary_op (const op_location_t &location,
/* Tree holding instrumentation expression. */
tree instrument_expr = NULL_TREE;
+ /* Apply default conversions. */
+ op0 = resolve_nondeduced_context (orig_op0, complain);
+ op1 = resolve_nondeduced_context (orig_op1, complain);
+
if (code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR
|| code == TRUTH_OR_EXPR || code == TRUTH_ORIF_EXPR
|| code == TRUTH_XOR_EXPR)
@@ -6204,11 +6204,13 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
if (!arg || error_operand_p (arg))
return error_mark_node;
+ arg = resolve_nondeduced_context (arg, complain);
+
if ((invalid_op_diag
= targetm.invalid_unary_op ((code == UNARY_PLUS_EXPR
? CONVERT_EXPR
: code),
- TREE_TYPE (xarg))))
+ TREE_TYPE (arg))))
{
if (complain & tf_error)
error (invalid_op_diag);
diff --git a/gcc/testsuite/g++.dg/template/operator15.C b/gcc/testsuite/g++.dg/template/operator15.C
new file mode 100644
index 00000000000..755442266bb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/operator15.C
@@ -0,0 +1,6 @@
+// PR c++/60531
+
+template < class T > T foo ();
+
+bool b1 = foo<int> == foo<int>;
+int (*fp1)() = +foo<int>;
^ permalink raw reply [flat|nested] 5+ messages in thread
* [C++ PATCH, PING] PR60531 - Wrong error about unresolved overloaded function
2019-04-13 11:54 [C++ PATCH] PR60531 - Wrong error about unresolved overloaded function Harald van Dijk
@ 2019-04-26 20:31 ` Harald van Dijk
2019-05-12 16:57 ` [C++ PATCH, PING^2] " Harald van Dijk
0 siblings, 1 reply; 5+ messages in thread
From: Harald van Dijk @ 2019-04-26 20:31 UTC (permalink / raw)
To: gcc-patches
ping
On 13/04/2019 10:01, Harald van Dijk wrote:
> Hi,
>
> For PR60531, GCC wrongly rejects function templates with explicitly
> specified template arguments as overloaded. They are resolved by
> resolve_nondeduced_context, which is normally called by
> cp_default_conversion through decay_conversion, but the latter have
> extra effects making them unusable here. Calling the former directly
> does work.
>
> Bootstrapped on x86_64-pc-linux-gnu on top of r270264 with
> --enable-languages=all; make check shows no regressions.
>
> Does this look okay?
>
> This is my first code contribution to GCC, please let me know if
> anything is missing. I have not signed any copyright disclaimer or
> copyright assignment; <Contributing to GCC> says that is not necessary
> for small changes, which I trust this is. If it is needed after all,
> please let me know what specifically will be required.
>
> Cheers,
> Harald van Dijk
>
> Â Â Â Â PR c++/60531
> Â Â Â Â * typeck.c (cp_build_binary_op): See if overload can be resolved.
> Â Â Â Â (cp_build_unary_op): Ditto.
>
> Â Â Â Â * g++.dg/template/operator15.C: New test.
>
> diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
> index 03b14024738..e1ffe88ce2c 100644
> --- a/gcc/cp/typeck.c
> +++ b/gcc/cp/typeck.c
> @@ -4384,10 +4384,6 @@ cp_build_binary_op (const op_location_t &location,
>   /* True if both operands have arithmetic type. */
> Â Â bool arithmetic_types_p;
>
> - /* Apply default conversions. */
> -Â op0 = orig_op0;
> -Â op1 = orig_op1;
> -
>   /* Remember whether we're doing / or %. */
> Â Â bool doing_div_or_mod = false;
>
> @@ -4397,6 +4393,10 @@ cp_build_binary_op (const op_location_t &location,
>   /* Tree holding instrumentation expression. */
> Â Â tree instrument_expr = NULL_TREE;
>
> + /* Apply default conversions. */
> +Â op0 = resolve_nondeduced_context (orig_op0, complain);
> +Â op1 = resolve_nondeduced_context (orig_op1, complain);
> +
> Â Â if (code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR
> Â Â Â Â Â Â || code == TRUTH_OR_EXPR || code == TRUTH_ORIF_EXPR
> Â Â Â Â Â Â || code == TRUTH_XOR_EXPR)
> @@ -6204,11 +6204,13 @@ cp_build_unary_op (enum tree_code code, tree
> xarg, bool noconvert,
> Â Â if (!arg || error_operand_p (arg))
> Â Â Â Â return error_mark_node;
>
> +Â arg = resolve_nondeduced_context (arg, complain);
> +
> Â Â if ((invalid_op_diag
> Â Â Â Â Â Â Â = targetm.invalid_unary_op ((code == UNARY_PLUS_EXPR
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ? CONVERT_EXPR
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â : code),
> -Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â TREE_TYPE (xarg))))
> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â TREE_TYPE (arg))))
> Â Â Â Â {
> Â Â Â Â Â Â if (complain & tf_error)
> Â Â Â Â error (invalid_op_diag);
> diff --git a/gcc/testsuite/g++.dg/template/operator15.C
> b/gcc/testsuite/g++.dg/template/operator15.C
> new file mode 100644
> index 00000000000..755442266bb
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/template/operator15.C
> @@ -0,0 +1,6 @@
> +// PR c++/60531
> +
> +template < class T > T foo ();
> +
> +bool b1 = foo<int> == foo<int>;
> +int (*fp1)() = +foo<int>;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [C++ PATCH, PING^2] PR60531 - Wrong error about unresolved overloaded function
2019-04-26 20:31 ` [C++ PATCH, PING] " Harald van Dijk
@ 2019-05-12 16:57 ` Harald van Dijk
2019-05-31 19:17 ` [C++ PATCH, PING^3] " Harald van Dijk
0 siblings, 1 reply; 5+ messages in thread
From: Harald van Dijk @ 2019-05-12 16:57 UTC (permalink / raw)
To: gcc-patches
ping again
On 26/04/2019 19:58, Harald van Dijk wrote:
> ping
>
> On 13/04/2019 10:01, Harald van Dijk wrote:
>> Hi,
>>
>> For PR60531, GCC wrongly rejects function templates with explicitly
>> specified template arguments as overloaded. They are resolved by
>> resolve_nondeduced_context, which is normally called by
>> cp_default_conversion through decay_conversion, but the latter have
>> extra effects making them unusable here. Calling the former directly
>> does work.
>>
>> Bootstrapped on x86_64-pc-linux-gnu on top of r270264 with
>> --enable-languages=all; make check shows no regressions.
>>
>> Does this look okay?
>>
>> This is my first code contribution to GCC, please let me know if
>> anything is missing. I have not signed any copyright disclaimer or
>> copyright assignment; <Contributing to GCC> says that is not necessary
>> for small changes, which I trust this is. If it is needed after all,
>> please let me know what specifically will be required.
>>
>> Cheers,
>> Harald van Dijk
>>
>> Â Â Â Â Â PR c++/60531
>> Â Â Â Â Â * typeck.c (cp_build_binary_op): See if overload can be resolved.
>> Â Â Â Â Â (cp_build_unary_op): Ditto.
>>
>> Â Â Â Â Â * g++.dg/template/operator15.C: New test.
>>
>> diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
>> index 03b14024738..e1ffe88ce2c 100644
>> --- a/gcc/cp/typeck.c
>> +++ b/gcc/cp/typeck.c
>> @@ -4384,10 +4384,6 @@ cp_build_binary_op (const op_location_t &location,
>>    /* True if both operands have arithmetic type. */
>> Â Â Â bool arithmetic_types_p;
>>
>> - /* Apply default conversions. */
>> -Â op0 = orig_op0;
>> -Â op1 = orig_op1;
>> -
>>    /* Remember whether we're doing / or %. */
>> Â Â Â bool doing_div_or_mod = false;
>>
>> @@ -4397,6 +4393,10 @@ cp_build_binary_op (const op_location_t &location,
>>    /* Tree holding instrumentation expression. */
>> Â Â Â tree instrument_expr = NULL_TREE;
>>
>> + /* Apply default conversions. */
>> +Â op0 = resolve_nondeduced_context (orig_op0, complain);
>> +Â op1 = resolve_nondeduced_context (orig_op1, complain);
>> +
>> Â Â Â if (code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR
>> Â Â Â Â Â Â Â || code == TRUTH_OR_EXPR || code == TRUTH_ORIF_EXPR
>> Â Â Â Â Â Â Â || code == TRUTH_XOR_EXPR)
>> @@ -6204,11 +6204,13 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
>> Â Â Â if (!arg || error_operand_p (arg))
>> Â Â Â Â Â return error_mark_node;
>>
>> +Â arg = resolve_nondeduced_context (arg, complain);
>> +
>> Â Â Â if ((invalid_op_diag
>> Â Â Â Â Â Â Â Â = targetm.invalid_unary_op ((code == UNARY_PLUS_EXPR
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ? CONVERT_EXPR
>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â : code),
>> -Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â TREE_TYPE (xarg))))
>> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â TREE_TYPE (arg))))
>> Â Â Â Â Â {
>> Â Â Â Â Â Â Â if (complain & tf_error)
>> Â Â Â Â Â error (invalid_op_diag);
>> diff --git a/gcc/testsuite/g++.dg/template/operator15.C b/gcc/testsuite/g++.dg/template/operator15.C
>> new file mode 100644
>> index 00000000000..755442266bb
>> --- /dev/null
>> +++ b/gcc/testsuite/g++.dg/template/operator15.C
>> @@ -0,0 +1,6 @@
>> +// PR c++/60531
>> +
>> +template < class T > T foo ();
>> +
>> +bool b1 = foo<int> == foo<int>;
>> +int (*fp1)() = +foo<int>;
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [C++ PATCH, PING^3] PR60531 - Wrong error about unresolved overloaded function
2019-05-12 16:57 ` [C++ PATCH, PING^2] " Harald van Dijk
@ 2019-05-31 19:17 ` Harald van Dijk
2019-06-04 14:49 ` Jason Merrill
0 siblings, 1 reply; 5+ messages in thread
From: Harald van Dijk @ 2019-05-31 19:17 UTC (permalink / raw)
To: gcc-patches
another ping
On 12/05/2019 17:57, Harald van Dijk wrote:
> ping again
>
> On 26/04/2019 19:58, Harald van Dijk wrote:
>> ping
>>
>> On 13/04/2019 10:01, Harald van Dijk wrote:
>>> Hi,
>>>
>>> For PR60531, GCC wrongly rejects function templates with explicitly
>>> specified template arguments as overloaded. They are resolved by
>>> resolve_nondeduced_context, which is normally called by
>>> cp_default_conversion through decay_conversion, but the latter have
>>> extra effects making them unusable here. Calling the former directly
>>> does work.
>>>
>>> Bootstrapped on x86_64-pc-linux-gnu on top of r270264 with
>>> --enable-languages=all; make check shows no regressions.
>>>
>>> Does this look okay?
>>>
>>> This is my first code contribution to GCC, please let me know if
>>> anything is missing. I have not signed any copyright disclaimer or
>>> copyright assignment; <Contributing to GCC> says that is not necessary
>>> for small changes, which I trust this is. If it is needed after all,
>>> please let me know what specifically will be required.
>>>
>>> Cheers,
>>> Harald van Dijk
>>>
>>> Â Â Â Â Â PR c++/60531
>>> Â Â Â Â Â * typeck.c (cp_build_binary_op): See if overload can be resolved.
>>> Â Â Â Â Â (cp_build_unary_op): Ditto.
>>>
>>> Â Â Â Â Â * g++.dg/template/operator15.C: New test.
>>>
>>> diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
>>> index 03b14024738..e1ffe88ce2c 100644
>>> --- a/gcc/cp/typeck.c
>>> +++ b/gcc/cp/typeck.c
>>> @@ -4384,10 +4384,6 @@ cp_build_binary_op (const op_location_t &location,
>>>    /* True if both operands have arithmetic type. */
>>> Â Â Â bool arithmetic_types_p;
>>>
>>> - /* Apply default conversions. */
>>> -Â op0 = orig_op0;
>>> -Â op1 = orig_op1;
>>> -
>>>    /* Remember whether we're doing / or %. */
>>> Â Â Â bool doing_div_or_mod = false;
>>>
>>> @@ -4397,6 +4393,10 @@ cp_build_binary_op (const op_location_t &location,
>>>    /* Tree holding instrumentation expression. */
>>> Â Â Â tree instrument_expr = NULL_TREE;
>>>
>>> + /* Apply default conversions. */
>>> +Â op0 = resolve_nondeduced_context (orig_op0, complain);
>>> +Â op1 = resolve_nondeduced_context (orig_op1, complain);
>>> +
>>> Â Â Â if (code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR
>>> Â Â Â Â Â Â Â || code == TRUTH_OR_EXPR || code == TRUTH_ORIF_EXPR
>>> Â Â Â Â Â Â Â || code == TRUTH_XOR_EXPR)
>>> @@ -6204,11 +6204,13 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
>>> Â Â Â if (!arg || error_operand_p (arg))
>>> Â Â Â Â Â return error_mark_node;
>>>
>>> +Â arg = resolve_nondeduced_context (arg, complain);
>>> +
>>> Â Â Â if ((invalid_op_diag
>>> Â Â Â Â Â Â Â Â = targetm.invalid_unary_op ((code == UNARY_PLUS_EXPR
>>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ? CONVERT_EXPR
>>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â : code),
>>> -Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â TREE_TYPE (xarg))))
>>> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â TREE_TYPE (arg))))
>>> Â Â Â Â Â {
>>> Â Â Â Â Â Â Â if (complain & tf_error)
>>> Â Â Â Â Â error (invalid_op_diag);
>>> diff --git a/gcc/testsuite/g++.dg/template/operator15.C b/gcc/testsuite/g++.dg/template/operator15.C
>>> new file mode 100644
>>> index 00000000000..755442266bb
>>> --- /dev/null
>>> +++ b/gcc/testsuite/g++.dg/template/operator15.C
>>> @@ -0,0 +1,6 @@
>>> +// PR c++/60531
>>> +
>>> +template < class T > T foo ();
>>> +
>>> +bool b1 = foo<int> == foo<int>;
>>> +int (*fp1)() = +foo<int>;
>>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [C++ PATCH, PING^3] PR60531 - Wrong error about unresolved overloaded function
2019-05-31 19:17 ` [C++ PATCH, PING^3] " Harald van Dijk
@ 2019-06-04 14:49 ` Jason Merrill
0 siblings, 0 replies; 5+ messages in thread
From: Jason Merrill @ 2019-06-04 14:49 UTC (permalink / raw)
To: Harald van Dijk, gcc-patches
Applied, thanks for your persistence.
On 5/31/19 3:06 PM, Harald van Dijk wrote:
> another ping
>
> On 12/05/2019 17:57, Harald van Dijk wrote:
>> ping again
>>
>> On 26/04/2019 19:58, Harald van Dijk wrote:
>>> ping
>>>
>>> On 13/04/2019 10:01, Harald van Dijk wrote:
>>>> Hi,
>>>>
>>>> For PR60531, GCC wrongly rejects function templates with explicitly
>>>> specified template arguments as overloaded. They are resolved by
>>>> resolve_nondeduced_context, which is normally called by
>>>> cp_default_conversion through decay_conversion, but the latter have
>>>> extra effects making them unusable here. Calling the former directly
>>>> does work.
>>>>
>>>> Bootstrapped on x86_64-pc-linux-gnu on top of r270264 with
>>>> --enable-languages=all; make check shows no regressions.
>>>>
>>>> Does this look okay?
>>>>
>>>> This is my first code contribution to GCC, please let me know if
>>>> anything is missing. I have not signed any copyright disclaimer or
>>>> copyright assignment; <Contributing to GCC> says that is not necessary
>>>> for small changes, which I trust this is. If it is needed after all,
>>>> please let me know what specifically will be required.
>>>>
>>>> Cheers,
>>>> Harald van Dijk
>>>>
>>>> Â Â Â Â Â PR c++/60531
>>>> Â Â Â Â Â * typeck.c (cp_build_binary_op): See if overload can be resolved.
>>>> Â Â Â Â Â (cp_build_unary_op): Ditto.
>>>>
>>>> Â Â Â Â Â * g++.dg/template/operator15.C: New test.
>>>>
>>>> diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
>>>> index 03b14024738..e1ffe88ce2c 100644
>>>> --- a/gcc/cp/typeck.c
>>>> +++ b/gcc/cp/typeck.c
>>>> @@ -4384,10 +4384,6 @@ cp_build_binary_op (const op_location_t
>>>> &location,
>>>>    /* True if both operands have arithmetic type. */
>>>> Â Â Â bool arithmetic_types_p;
>>>>
>>>> - /* Apply default conversions. */
>>>> -Â op0 = orig_op0;
>>>> -Â op1 = orig_op1;
>>>> -
>>>>    /* Remember whether we're doing / or %. */
>>>> Â Â Â bool doing_div_or_mod = false;
>>>>
>>>> @@ -4397,6 +4393,10 @@ cp_build_binary_op (const op_location_t
>>>> &location,
>>>>    /* Tree holding instrumentation expression. */
>>>> Â Â Â tree instrument_expr = NULL_TREE;
>>>>
>>>> + /* Apply default conversions. */
>>>> +Â op0 = resolve_nondeduced_context (orig_op0, complain);
>>>> +Â op1 = resolve_nondeduced_context (orig_op1, complain);
>>>> +
>>>> Â Â Â if (code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR
>>>> Â Â Â Â Â Â Â || code == TRUTH_OR_EXPR || code == TRUTH_ORIF_EXPR
>>>> Â Â Â Â Â Â Â || code == TRUTH_XOR_EXPR)
>>>> @@ -6204,11 +6204,13 @@ cp_build_unary_op (enum tree_code code, tree
>>>> xarg, bool noconvert,
>>>> Â Â Â if (!arg || error_operand_p (arg))
>>>> Â Â Â Â Â return error_mark_node;
>>>>
>>>> +Â arg = resolve_nondeduced_context (arg, complain);
>>>> +
>>>> Â Â Â if ((invalid_op_diag
>>>> Â Â Â Â Â Â Â Â = targetm.invalid_unary_op ((code == UNARY_PLUS_EXPR
>>>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ? CONVERT_EXPR
>>>> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â : code),
>>>> -Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â TREE_TYPE (xarg))))
>>>> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â TREE_TYPE (arg))))
>>>> Â Â Â Â Â {
>>>> Â Â Â Â Â Â Â if (complain & tf_error)
>>>> Â Â Â Â Â error (invalid_op_diag);
>>>> diff --git a/gcc/testsuite/g++.dg/template/operator15.C
>>>> b/gcc/testsuite/g++.dg/template/operator15.C
>>>> new file mode 100644
>>>> index 00000000000..755442266bb
>>>> --- /dev/null
>>>> +++ b/gcc/testsuite/g++.dg/template/operator15.C
>>>> @@ -0,0 +1,6 @@
>>>> +// PR c++/60531
>>>> +
>>>> +template < class T > T foo ();
>>>> +
>>>> +bool b1 = foo<int> == foo<int>;
>>>> +int (*fp1)() = +foo<int>;
>>>>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-06-04 14:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-13 11:54 [C++ PATCH] PR60531 - Wrong error about unresolved overloaded function Harald van Dijk
2019-04-26 20:31 ` [C++ PATCH, PING] " Harald van Dijk
2019-05-12 16:57 ` [C++ PATCH, PING^2] " Harald van Dijk
2019-05-31 19:17 ` [C++ PATCH, PING^3] " Harald van Dijk
2019-06-04 14:49 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).