public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Patrick Palka <ppalka@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: gcc-patches@gcc.gnu.org, waffl3x <waffl3x@protonmail.com>
Subject: Re: [pushed] c++: remove LAMBDA_EXPR_MUTABLE_P
Date: Fri, 1 Dec 2023 14:03:28 -0500 (EST)	[thread overview]
Message-ID: <f0253f64-2332-6ed6-c58b-cfcb55e55c45@idea> (raw)
In-Reply-To: <20231130050027.700656-1-jason@redhat.com>

On Thu, 30 Nov 2023, Jason Merrill wrote:

> Tested x86_64-pc-linux-gnu, applying to trunk.
> 
> -- 8< --
> 
> In review of the deducing 'this' patch it came up that LAMBDA_EXPR_MUTABLE_P
> doesn't make sense for a lambda with an explicit object parameter.  And it
> was never necessary, so let's remove it.
> 
> gcc/cp/ChangeLog:
> 
> 	* cp-tree.h (LAMBDA_EXPR_MUTABLE_P): Remove.
> 	* cp-tree.def: Remove documentation.
> 	* lambda.cc (build_lambda_expr): Remove reference.
> 	* parser.cc (cp_parser_lambda_declarator_opt): Likewise.
> 	* pt.cc (tsubst_lambda_expr): Likewise.
> 	* ptree.cc (cxx_print_lambda_node): Likewise.
> 	* semantics.cc (capture_decltype): Get the object quals
> 	from the object instead.
> ---
>  gcc/cp/cp-tree.h    | 5 -----
>  gcc/cp/lambda.cc    | 1 -
>  gcc/cp/parser.cc    | 1 -
>  gcc/cp/pt.cc        | 1 -
>  gcc/cp/ptree.cc     | 2 --
>  gcc/cp/semantics.cc | 9 ++++++---
>  gcc/cp/cp-tree.def  | 3 +--
>  7 files changed, 7 insertions(+), 15 deletions(-)
> 
> diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
> index 5614b71eed4..964af1ddd85 100644
> --- a/gcc/cp/cp-tree.h
> +++ b/gcc/cp/cp-tree.h
> @@ -461,7 +461,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
>        TYPENAME_IS_CLASS_P (in TYPENAME_TYPE)
>        STMT_IS_FULL_EXPR_P (in _STMT)
>        TARGET_EXPR_LIST_INIT_P (in TARGET_EXPR)
> -      LAMBDA_EXPR_MUTABLE_P (in LAMBDA_EXPR)
>        DECL_FINAL_P (in FUNCTION_DECL)
>        QUALIFIED_NAME_IS_TEMPLATE (in SCOPE_REF)
>        CONSTRUCTOR_IS_DEPENDENT (in CONSTRUCTOR)
> @@ -1478,10 +1477,6 @@ enum cp_lambda_default_capture_mode_type {
>  #define LAMBDA_EXPR_CAPTURES_THIS_P(NODE) \
>    LAMBDA_EXPR_THIS_CAPTURE(NODE)
>  
> -/* Predicate tracking whether the lambda was declared 'mutable'.  */
> -#define LAMBDA_EXPR_MUTABLE_P(NODE) \
> -  TREE_LANG_FLAG_1 (LAMBDA_EXPR_CHECK (NODE))
> -
>  /* True iff uses of a const variable capture were optimized away.  */
>  #define LAMBDA_EXPR_CAPTURE_OPTIMIZED(NODE) \
>    TREE_LANG_FLAG_2 (LAMBDA_EXPR_CHECK (NODE))
> diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc
> index 34d0190a89b..be8d240944d 100644
> --- a/gcc/cp/lambda.cc
> +++ b/gcc/cp/lambda.cc
> @@ -44,7 +44,6 @@ build_lambda_expr (void)
>    LAMBDA_EXPR_THIS_CAPTURE         (lambda) = NULL_TREE;
>    LAMBDA_EXPR_REGEN_INFO           (lambda) = NULL_TREE;
>    LAMBDA_EXPR_PENDING_PROXIES      (lambda) = NULL;
> -  LAMBDA_EXPR_MUTABLE_P            (lambda) = false;
>    return lambda;
>  }
>  
> diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
> index 2464d1a0783..1826b6175f5 100644
> --- a/gcc/cp/parser.cc
> +++ b/gcc/cp/parser.cc
> @@ -11770,7 +11770,6 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)
>  
>    if (lambda_specs.storage_class == sc_mutable)
>      {
> -      LAMBDA_EXPR_MUTABLE_P (lambda_expr) = 1;
>        quals = TYPE_UNQUALIFIED;
>      }
>    else if (lambda_specs.storage_class == sc_static)
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index c18718b319d..00a808bf323 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -19341,7 +19341,6 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>      = LAMBDA_EXPR_LOCATION (t);
>    LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (r)
>      = LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (t);
> -  LAMBDA_EXPR_MUTABLE_P (r) = LAMBDA_EXPR_MUTABLE_P (t);
>    if (tree ti = LAMBDA_EXPR_REGEN_INFO (t))
>      LAMBDA_EXPR_REGEN_INFO (r)
>        = build_template_info (t, add_to_template_args (TI_ARGS (ti),
> diff --git a/gcc/cp/ptree.cc b/gcc/cp/ptree.cc
> index 32c5b5280dc..d1f58921fab 100644
> --- a/gcc/cp/ptree.cc
> +++ b/gcc/cp/ptree.cc
> @@ -265,8 +265,6 @@ cxx_print_identifier (FILE *file, tree node, int indent)
>  void
>  cxx_print_lambda_node (FILE *file, tree node, int indent)
>  {
> -  if (LAMBDA_EXPR_MUTABLE_P (node))
> -    fprintf (file, " /mutable");
>    fprintf (file, " default_capture_mode=[");
>    switch (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (node))
>      {
> diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
> index 04b0540599a..36b57ac9524 100644
> --- a/gcc/cp/semantics.cc
> +++ b/gcc/cp/semantics.cc
> @@ -12792,9 +12792,12 @@ capture_decltype (tree decl)
>  
>    if (!TYPE_REF_P (type))
>      {
> -      if (!LAMBDA_EXPR_MUTABLE_P (lam))
> -	type = cp_build_qualified_type (type, (cp_type_quals (type)
> -					       |TYPE_QUAL_CONST));
> +      int quals = cp_type_quals (type);
> +      tree obtype = TREE_TYPE (DECL_ARGUMENTS (current_function_decl));
> +      gcc_checking_assert (!WILDCARD_TYPE_P (non_reference (obtype)));
> +      if (INDIRECT_TYPE_P (obtype))
> +	quals |= cp_type_quals (TREE_TYPE (obtype));

Shouldn't we propagate cv-quals of a by-value object parameter as well?

> +      type = cp_build_qualified_type (type, quals);
>        type = build_reference_type (type);
>      }
>    return type;
> diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
> index bf3bcd1bf13..fe47b0a10e6 100644
> --- a/gcc/cp/cp-tree.def
> +++ b/gcc/cp/cp-tree.def
> @@ -446,8 +446,7 @@ DEFTREECODE (TRAIT_TYPE, "trait_type", tcc_type, 0)
>     LAMBDA_EXPR_CAPTURE_LIST holds the capture-list, including `this'.
>     LAMBDA_EXPR_THIS_CAPTURE goes straight to the capture of `this', if it exists.
>     LAMBDA_EXPR_PENDING_PROXIES is a vector of capture proxies which need to
> -   be pushed once scope returns to the lambda.
> -   LAMBDA_EXPR_MUTABLE_P signals whether this lambda was declared mutable.  */
> +   be pushed once scope returns to the lambda.  */
>  DEFTREECODE (LAMBDA_EXPR, "lambda_expr", tcc_exceptional, 0)
>  
>  /* The declared type of an expression.  This is a C++0x extension.
> 
> base-commit: fc7b70fa3497664a58b3c0b36fa94f9ec87d4f22
> -- 
> 2.39.3
> 
> 


      parent reply	other threads:[~2023-12-01 19:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30  5:00 Jason Merrill
2023-12-01  3:50 ` [PATCH] c++: lambda capture and explicit object parm Jason Merrill
2023-12-01 19:03 ` Patrick Palka [this message]

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=f0253f64-2332-6ed6-c58b-cfcb55e55c45@idea \
    --to=ppalka@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=waffl3x@protonmail.com \
    /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).