public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-7398] c++: (*(fn))() [PR104618]
Date: Sun, 27 Feb 2022 22:52:42 +0000 (GMT)	[thread overview]
Message-ID: <20220227225242.283613858426@sourceware.org> (raw)

https://gcc.gnu.org/g:0096b0b467b2c98ed258f0ead9a8b87b2a6d8466

commit r12-7398-g0096b0b467b2c98ed258f0ead9a8b87b2a6d8466
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Feb 25 15:26:17 2022 -0400

    c++: (*(fn))() [PR104618]
    
    The patch for PR90451 deferred marking to the point of actual use; we missed
    this one because of the parens.
    
            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.

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

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)) ();
+}


                 reply	other threads:[~2022-02-27 22:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220227225242.283613858426@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).