]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: remove LAMBDA_EXPR_MUTABLE_P
authorJason Merrill <jason@redhat.com>
Wed, 29 Nov 2023 23:08:23 +0000 (18:08 -0500)
committerJason Merrill <jason@redhat.com>
Thu, 30 Nov 2023 04:55:55 +0000 (23:55 -0500)
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.def
gcc/cp/cp-tree.h
gcc/cp/lambda.cc
gcc/cp/parser.cc
gcc/cp/pt.cc
gcc/cp/ptree.cc
gcc/cp/semantics.cc

index bf3bcd1bf13bd82835342a52a055db869cdbd4ab..fe47b0a10e60c2953b4a85335a5cd5d07f6a9463 100644 (file)
@@ -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.
index 5614b71eed4cde1b890f38f966d810bdf4e5beb6..964af1ddd85c58ecd27ff271700fc276e96dfddc 100644 (file)
@@ -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))
index 34d0190a89bbf1c6488ed6e4e8a35126a029562b..be8d240944d778f20e46d5a1298424f5ffe2435c 100644 (file)
@@ -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;
 }
 
index 2464d1a078394ef5e83abfe92eea8a28cdcd47ef..1826b6175f5069ee6553229822cb64cfab53854a 100644 (file)
@@ -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)
index c18718b319dfc55e0dc8a6f813898198261f65dc..00a808bf32311146009ecf77c818727c2016623d 100644 (file)
@@ -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),
index 32c5b5280dcb69753f734c90e6e0c3d5e4307d69..d1f58921fabfe99576aa14fdc130fa759992a5bf 100644 (file)
@@ -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))
     {
index 04b0540599a4eb48e8259054eb86eac5a1dca7a6..36b57ac9524d61498014eb6906607df1c4bf6009 100644 (file)
@@ -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;