public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed] c++: remove LAMBDA_EXPR_MUTABLE_P
@ 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 ` [pushed] c++: remove LAMBDA_EXPR_MUTABLE_P Patrick Palka
  0 siblings, 2 replies; 3+ messages in thread
From: Jason Merrill @ 2023-11-30  5:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: waffl3x

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


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

end of thread, other threads:[~2023-12-01 19:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-30  5:00 [pushed] c++: remove LAMBDA_EXPR_MUTABLE_P Jason Merrill
2023-12-01  3:50 ` [PATCH] c++: lambda capture and explicit object parm Jason Merrill
2023-12-01 19:03 ` [pushed] c++: remove LAMBDA_EXPR_MUTABLE_P Patrick Palka

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).