public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: Fix up mangling of static lambdas [PR108525]
@ 2023-01-24 23:19 Jakub Jelinek
  2023-01-25 14:08 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2023-01-24 23:19 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

Hi!

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.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

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.

--- gcc/cp/mangle.cc.jj	2023-01-16 11:52:16.000000000 +0100
+++ gcc/cp/mangle.cc	2023-01-24 18:59:09.335156301 +0100
@@ -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))
--- gcc/testsuite/g++.dg/cpp23/static-operator-call5.C.jj	2023-01-24 19:03:21.770469929 +0100
+++ gcc/testsuite/g++.dg/cpp23/static-operator-call5.C	2023-01-24 19:02:45.224003615 +0100
@@ -0,0 +1,5 @@
+// PR c++/108525
+// { dg-do compile { target c++23 } }
+
+auto b = [](...) static { return 1; };
+auto foo () { return b (); }

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] c++: Fix up mangling of static lambdas [PR108525]
  2023-01-24 23:19 [PATCH] c++: Fix up mangling of static lambdas [PR108525] Jakub Jelinek
@ 2023-01-25 14:08 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2023-01-25 14:08 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On 1/24/23 18:19, Jakub Jelinek wrote:
> Hi!
> 
> 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.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

> 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.
> 
> --- gcc/cp/mangle.cc.jj	2023-01-16 11:52:16.000000000 +0100
> +++ gcc/cp/mangle.cc	2023-01-24 18:59:09.335156301 +0100
> @@ -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))
> --- gcc/testsuite/g++.dg/cpp23/static-operator-call5.C.jj	2023-01-24 19:03:21.770469929 +0100
> +++ gcc/testsuite/g++.dg/cpp23/static-operator-call5.C	2023-01-24 19:02:45.224003615 +0100
> @@ -0,0 +1,5 @@
> +// PR c++/108525
> +// { dg-do compile { target c++23 } }
> +
> +auto b = [](...) static { return 1; };
> +auto foo () { return b (); }
> 
> 	Jakub
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-25 14:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-24 23:19 [PATCH] c++: Fix up mangling of static lambdas [PR108525] Jakub Jelinek
2023-01-25 14:08 ` 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).