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 r13-6533] c++: static lambda tsubst [PR108526]
Date: Tue,  7 Mar 2023 19:34:18 +0000 (GMT)	[thread overview]
Message-ID: <20230307193418.1BB09385086C@sourceware.org> (raw)

https://gcc.gnu.org/g:4f181f9c7ee3efc509d185fdfda33be9018f1611

commit r13-6533-g4f181f9c7ee3efc509d185fdfda33be9018f1611
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Mar 6 21:36:28 2023 -0500

    c++: static lambda tsubst [PR108526]
    
    A missed piece of the patch for static operator(): in tsubst_function_decl,
    we don't want to replace the first parameter with a new closure pointer if
    operator() is static.
    
            PR c++/108526
            PR c++/106651
    
    gcc/cp/ChangeLog:
    
            * pt.cc (tsubst_function_decl): Don't replace the closure
            parameter if DECL_STATIC_FUNCTION_P.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp23/static-operator-call5.C: Pass -g.

Diff:
---
 gcc/cp/pt.cc                                       | 4 ++--
 gcc/testsuite/g++.dg/cpp23/static-operator-call5.C | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 85136df1730..aafc99d12c3 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -14393,12 +14393,12 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain,
     DECL_NAME (r) = make_conv_op_name (TREE_TYPE (type));
 
   tree parms = DECL_ARGUMENTS (t);
-  if (closure)
+  if (closure && !DECL_STATIC_FUNCTION_P (t))
     parms = DECL_CHAIN (parms);
   parms = tsubst (parms, args, complain, t);
   for (tree parm = parms; parm; parm = DECL_CHAIN (parm))
     DECL_CONTEXT (parm) = r;
-  if (closure)
+  if (closure && !DECL_STATIC_FUNCTION_P (t))
     {
       tree tparm = build_this_parm (r, closure, type_memfn_quals (type));
       DECL_NAME (tparm) = closure_identifier;
diff --git a/gcc/testsuite/g++.dg/cpp23/static-operator-call5.C b/gcc/testsuite/g++.dg/cpp23/static-operator-call5.C
index ae022d0b971..f7ce8c03008 100644
--- a/gcc/testsuite/g++.dg/cpp23/static-operator-call5.C
+++ b/gcc/testsuite/g++.dg/cpp23/static-operator-call5.C
@@ -1,5 +1,6 @@
 // PR c++/108526
 // { dg-do compile { target c++23 } }
+// { dg-additional-options -g } PR108706
 
 template<class> void f()
 {

                 reply	other threads:[~2023-03-07 19:34 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=20230307193418.1BB09385086C@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).