public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-5372] c++: Fix up mangling of static lambdas [PR108525]
Date: Wed, 25 Jan 2023 14:14:10 +0000 (GMT)	[thread overview]
Message-ID: <20230125141410.7C6763858D28@sourceware.org> (raw)

https://gcc.gnu.org/g:9d4c00cdaccc3decd07740e817387ce844ef3ac9

commit r13-5372-g9d4c00cdaccc3decd07740e817387ce844ef3ac9
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 25 15:13:30 2023 +0100

    c++: Fix up mangling of static lambdas [PR108525]
    
    Before the P1169R4 changes, operator () of a lambda was
    always a method, so it was fine to pass method_p = 1 unconditionally,
    but it isn't always the case, so this patch adds a check for whether
    it is a method or nor.
    
    2023-01-25  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/108525
            * mangle.cc (write_closure_type_name): Don't assume all
            lambda operator() fns are methods.
    
            * g++.dg/cpp23/static-operator-call5.C: New test.

Diff:
---
 gcc/cp/mangle.cc                                   | 2 +-
 gcc/testsuite/g++.dg/cpp23/static-operator-call5.C | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index 62e9f9fba6e..f2cda3be2cf 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -1816,7 +1816,7 @@ write_closure_type_name (const tree type)
       if (abi_warn_or_compat_version_crosses (18))
 	G.need_abi_warning = true;
 
-  write_method_parms (parms, /*method_p=*/1, fn);
+  write_method_parms (parms, TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE, fn);
   write_char ('E');
   if ((LAMBDA_EXPR_SCOPE_SIG_DISCRIMINATOR (lambda)
        != LAMBDA_EXPR_SCOPE_ONLY_DISCRIMINATOR (lambda))
diff --git a/gcc/testsuite/g++.dg/cpp23/static-operator-call5.C b/gcc/testsuite/g++.dg/cpp23/static-operator-call5.C
index ae022d0b971..ecbb843ef3c 100644
--- a/gcc/testsuite/g++.dg/cpp23/static-operator-call5.C
+++ b/gcc/testsuite/g++.dg/cpp23/static-operator-call5.C
@@ -1,3 +1,8 @@
+// PR c++/108525
+// { dg-do compile { target c++23 } }
+
+auto b = [](...) static { return 1; };
+auto foo () { return b (); }
 // PR c++/108526
 // { dg-do compile { target c++23 } }

                 reply	other threads:[~2023-01-25 14:14 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=20230125141410.7C6763858D28@sourceware.org \
    --to=jakub@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).