diff mbox series

[pushed] c++: (*(fn))() [PR104618]

Message ID 20220227225215.54574-1-jason@redhat.com
State New
Headers show
Series [pushed] c++: (*(fn))() [PR104618] | expand

Commit Message

Jason Merrill Feb. 27, 2022, 10:52 p.m. UTC
The patch for PR90451 deferred marking to the point of actual use; we missed
this one because of the parens.

Tested x86_64-pc-linux-gnu, applying to trunk.

	PR c++/104618

gcc/cp/ChangeLog:

	* typeck.cc (cp_build_addr_expr_1): Also
	maybe_undo_parenthesized_ref.

gcc/testsuite/ChangeLog:

	* g++.dg/overload/paren1.C: New test.
---
 gcc/cp/typeck.cc                       | 6 +++---
 gcc/testsuite/g++.dg/overload/paren1.C | 7 +++++++
 2 files changed, 10 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/overload/paren1.C


base-commit: d1574a9b820f17adb9004255e2018967e9be063b

Comments

Jason Merrill March 7, 2022, 11:32 p.m. UTC | #1
On 2/27/22 18:52, Jason Merrill wrote:
> The patch for PR90451 deferred marking to the point of actual use; we missed
> this one because of the parens.
> 
> Tested x86_64-pc-linux-gnu, applying to trunk.
> 
> 	PR c++/104618
> 
> gcc/cp/ChangeLog:
> 
> 	* typeck.cc (cp_build_addr_expr_1): Also
> 	maybe_undo_parenthesized_ref.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/overload/paren1.C: New test.
> ---
>   gcc/cp/typeck.cc                       | 6 +++---
>   gcc/testsuite/g++.dg/overload/paren1.C | 7 +++++++
>   2 files changed, 10 insertions(+), 3 deletions(-)
>   create mode 100644 gcc/testsuite/g++.dg/overload/paren1.C
> 
> diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
> index f796337f73c..bddc83759ad 100644
> --- a/gcc/cp/typeck.cc
> +++ b/gcc/cp/typeck.cc
> @@ -6884,9 +6884,9 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain)
>        so we can just form an ADDR_EXPR with the correct type.  */
>     if (processing_template_decl || TREE_CODE (arg) != COMPONENT_REF)
>       {
> -      tree stripped_arg = tree_strip_any_location_wrapper (arg);
> -      if (TREE_CODE (stripped_arg) == FUNCTION_DECL
> -	  && !mark_used (stripped_arg, complain) && !(complain & tf_error))
> +      tree stripped_arg
> +	= tree_strip_any_location_wrapper (maybe_undo_parenthesized_ref (arg));
> +      if (!mark_single_function (stripped_arg, complain))

It occurred to me that it would be cleaner to do the stripping in 
mark_single_function.
diff mbox series

Patch

diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index f796337f73c..bddc83759ad 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -6884,9 +6884,9 @@  cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain)
      so we can just form an ADDR_EXPR with the correct type.  */
   if (processing_template_decl || TREE_CODE (arg) != COMPONENT_REF)
     {
-      tree stripped_arg = tree_strip_any_location_wrapper (arg);
-      if (TREE_CODE (stripped_arg) == FUNCTION_DECL
-	  && !mark_used (stripped_arg, complain) && !(complain & tf_error))
+      tree stripped_arg
+	= tree_strip_any_location_wrapper (maybe_undo_parenthesized_ref (arg));
+      if (!mark_single_function (stripped_arg, complain))
 	return error_mark_node;
       val = build_address (arg);
       if (TREE_CODE (arg) == OFFSET_REF)
diff --git a/gcc/testsuite/g++.dg/overload/paren1.C b/gcc/testsuite/g++.dg/overload/paren1.C
new file mode 100644
index 00000000000..21421ae8726
--- /dev/null
+++ b/gcc/testsuite/g++.dg/overload/paren1.C
@@ -0,0 +1,7 @@ 
+// PR c++/104618
+
+extern void gen_addsi3 (void);
+void output_stack_adjust ()
+{
+  (*(gen_addsi3)) ();
+}