{"id":807265,"url":"http://patchwork.ozlabs.org/api/1.2/patches/807265/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/CADzB+2=ymiE35BtJ_B8K3SOBW1N4BqRRr+6u8d=Otx38jzTQCA@mail.gmail.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.2/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<CADzB+2=ymiE35BtJ_B8K3SOBW1N4BqRRr+6u8d=Otx38jzTQCA@mail.gmail.com>","list_archive_url":null,"date":"2017-08-29T20:15:37","name":"C++ PATCH to remove unnecessary LAMBDA_EXPR fields","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"1d3580ec14baca2e034fedd944dd2daf51f23011","submitter":{"id":4337,"url":"http://patchwork.ozlabs.org/api/1.2/people/4337/?format=json","name":"Jason Merrill","email":"jason@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/CADzB+2=ymiE35BtJ_B8K3SOBW1N4BqRRr+6u8d=Otx38jzTQCA@mail.gmail.com/mbox/","series":[{"id":461,"url":"http://patchwork.ozlabs.org/api/1.2/series/461/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=461","date":"2017-08-29T20:15:37","name":"C++ PATCH to remove unnecessary LAMBDA_EXPR fields","version":1,"mbox":"http://patchwork.ozlabs.org/series/461/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/807265/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/807265/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-461118-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461118-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"LV87Pbba\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xhfzJ2H1nz9sPt\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 06:16:11 +1000 (AEST)","(qmail 42832 invoked by alias); 29 Aug 2017 20:16:02 -0000","(qmail 42822 invoked by uid 89); 29 Aug 2017 20:16:01 -0000","from mail-io0-f181.google.com (HELO mail-io0-f181.google.com)\n\t(209.85.223.181) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tTue, 29 Aug 2017 20:15:59 +0000","by mail-io0-f181.google.com with SMTP id g33so21282251ioj.3 for\n\t<gcc-patches@gcc.gnu.org>; Tue, 29 Aug 2017 13:15:59 -0700 (PDT)","by 10.107.181.23 with HTTP; Tue, 29 Aug 2017 13:15:37 -0700 (PDT)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:from:date:message-id:subject:to:content-type; q=\n\tdns; s=default; b=aQ3tm4PdzFNf2PoZsRBFV04kYNvCA/dRvvg6p4ASAMAAn9\n\tOyYmOG0I38aDmjReVnp9alhtpUNhNV6jTgCo7+luFixewibgaj660IwFbWKdmGph\n\tzg73kqnbHAVTUfB00ov8k5TcKDZPJmUnJAoO83xGqW0kp+6t6v8FmnzdG3TXE=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:from:date:message-id:subject:to:content-type; s=\n\tdefault; bh=IU05e9ny8ghbahHm9MNjVMtveXM=; b=LV87Pbbahejs8bvZgXPg\n\tJhSlmo+jQp1ex8c8mwiMpMTZAnOnN2AqBtAXXdG7ziJq+UqpDEAy+a16G7/RclUW\n\tspA13zg6iCCkb7SEx19i6XTAMnNDu8PyReZxvjonkBupjD2SQEY/V0NktreVWaZK\n\toGvLuHHL1AVjOy1EDx+PTPU=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-24.1 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3,\n\tKAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_SORBS_SPAM autolearn=ham version=3.3.2\n\tspammy=HX-Received:sk:n64mr51, proxies","X-HELO":"mail-io0-f181.google.com","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net;\n\ts=20161025;\n\th=x-gm-message-state:mime-version:from:date:message-id:subject:to;\n\tbh=g52YOobdcM9EG0fuw53EPtgGcKlyc25RXK4p+QvY/14=;\n\tb=hVDc0zVViaAscFngLVgXEAl1oYioHjlYlzWKToEoJ2f0unayUFxAY+4M7gOFQyJarw\n\tHGGpE3SlOvqQzIud0wcsiSN8+xc24u+AQb3/1xAzgOmbndYgfDAuYZQjc8bzML8fZtlL\n\tGJPKMhlE4WXEPA/K9LVBTFXG8RzmNm7ODwIzPk6qtqrBw8DPX4Jyu7R7Paqrdw7Jj797\n\tn2nu+OW+HvIwBHdHB5oQVG9R0y84rC5FZYNyk/ZnAAK7ODxttVAKZsUkKMBENq5Ze26i\n\tHRNXhW8Dv2futrqDBrKcfBoouoLFnZnwUFiSO9HIwYOJQwkEO4NyyVoV1/KkNA0qsUFg\n\tCgtA==","X-Gm-Message-State":"AHYfb5iw8ohnoheW35aHhXGvHOp1wQNVhvoJbhuQtEdKp34pB/HhbQs4\tOHS33+eNvDnGijrbNI6y87XhM97dM5Rww2M=","X-Received":"by 10.107.164.67 with SMTP id n64mr5120307ioe.282.1504037757715;\n\tTue, 29 Aug 2017 13:15:57 -0700 (PDT)","MIME-Version":"1.0","From":"Jason Merrill <jason@redhat.com>","Date":"Tue, 29 Aug 2017 16:15:37 -0400","Message-ID":"<CADzB+2=ymiE35BtJ_B8K3SOBW1N4BqRRr+6u8d=Otx38jzTQCA@mail.gmail.com>","Subject":"C++ PATCH to remove unnecessary LAMBDA_EXPR fields","To":"gcc-patches List <gcc-patches@gcc.gnu.org>","Content-Type":"multipart/mixed; boundary=\"001a1141b89a4751a60557ea14dc\"","X-IsSubscribed":"yes"},"content":"The explicit return type for a lambda is only used during parsing, so\nwe can track it in a local variable.  Later on we can look at the\nactual return type of the function.\n\nSince tree_lambda_expr is typed, and the type of a lambda-expression\nis the closure, we can use TREE_TYPE for the closure instead of an\nadditional field.\n\nTested x86_64-pc-linux-gnu, applying to trunk.\ncommit f5fe57f1735a860988df4c3eb30c2340463852b7\nAuthor: Jason Merrill <jason@redhat.com>\nDate:   Thu Jul 6 17:37:15 2017 -0400\n\n            Remove unnecessary LAMBDA_EXPR fields.\n    \n            * cp-tree.h (LAMBDA_EXPR_CLOSURE): Use TREE_TYPE.\n            (LAMBDA_EXPR_RETURN_TYPE): Remove.\n            (struct tree_lambda_expr): Remove closure and return_type fields.\n            * lambda.c (build_lambda_expr): Don't set LAMBDA_EXPR_RETURN_TYPE.\n            * pt.c (tsubst_copy_and_build): Likewise.\n            * parser.c (cp_parser_lambda_declarator_opt): Track return type.\n            (cp_parser_lambda_body): Adjust unspecified return type check.\n            * ptree.c (cxx_print_lambda_node): Don't print closure or\n            return type.","diff":"diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def\nindex a46f9c3..890723f 100644\n--- a/gcc/cp/cp-tree.def\n+++ b/gcc/cp/cp-tree.def\n@@ -468,8 +468,7 @@ DEFTREECODE (TRAIT_EXPR, \"trait_expr\", tcc_exceptional, 0)\n    LAMBDA_EXPR_THIS_CAPTURE goes straight to the capture of `this', if it exists.\n    LAMBDA_EXPR_PENDING_PROXIES is a vector of capture proxies which need to\n    be pushed once scope returns to the lambda.\n-   LAMBDA_EXPR_MUTABLE_P signals whether this lambda was declared mutable.\n-   LAMBDA_EXPR_RETURN_TYPE holds the return type, if it was specified.  */\n+   LAMBDA_EXPR_MUTABLE_P signals whether this lambda was declared mutable.  */\n DEFTREECODE (LAMBDA_EXPR, \"lambda_expr\", tcc_exceptional, 0)\n \n /* The declared type of an expression.  This is a C++0x extension.\ndiff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h\nindex a58e7bd..ad97be4 100644\n--- a/gcc/cp/cp-tree.h\n+++ b/gcc/cp/cp-tree.h\n@@ -1253,11 +1253,6 @@ enum cp_lambda_default_capture_mode_type {\n #define LAMBDA_EXPR_MUTABLE_P(NODE) \\\n   TREE_LANG_FLAG_1 (LAMBDA_EXPR_CHECK (NODE))\n \n-/* The return type in the expression.\n- * NULL_TREE indicates that none was specified.  */\n-#define LAMBDA_EXPR_RETURN_TYPE(NODE) \\\n-  (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->return_type)\n-\n /* The source location of the lambda.  */\n #define LAMBDA_EXPR_LOCATION(NODE) \\\n   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->locus)\n@@ -1276,20 +1271,17 @@ enum cp_lambda_default_capture_mode_type {\n #define LAMBDA_EXPR_PENDING_PROXIES(NODE) \\\n   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->pending_proxies)\n \n-/* The closure type of the lambda.  Note that the TREE_TYPE of a\n-   LAMBDA_EXPR is always NULL_TREE, because we need to instantiate the\n-   LAMBDA_EXPR in order to instantiate the type.  */\n+/* The closure type of the lambda, which is also the type of the\n+   LAMBDA_EXPR.  */\n #define LAMBDA_EXPR_CLOSURE(NODE) \\\n-  (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->closure)\n+  (TREE_TYPE (LAMBDA_EXPR_CHECK (NODE)))\n \n struct GTY (()) tree_lambda_expr\n {\n   struct tree_typed typed;\n   tree capture_list;\n   tree this_capture;\n-  tree return_type;\n   tree extra_scope;\n-  tree closure;\n   vec<tree, va_gc> *pending_proxies;\n   location_t locus;\n   enum cp_lambda_default_capture_mode_type default_capture_mode;\ndiff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c\nindex 0e8934b..ff76178 100644\n--- a/gcc/cp/lambda.c\n+++ b/gcc/cp/lambda.c\n@@ -42,7 +42,6 @@ build_lambda_expr (void)\n   LAMBDA_EXPR_CAPTURE_LIST         (lambda) = NULL_TREE;\n   LAMBDA_EXPR_THIS_CAPTURE         (lambda) = NULL_TREE;\n   LAMBDA_EXPR_PENDING_PROXIES      (lambda) = NULL;\n-  LAMBDA_EXPR_RETURN_TYPE          (lambda) = NULL_TREE;\n   LAMBDA_EXPR_MUTABLE_P            (lambda) = false;\n   return lambda;\n }\ndiff --git a/gcc/cp/parser.c b/gcc/cp/parser.c\nindex 55f088d..07913d6 100644\n--- a/gcc/cp/parser.c\n+++ b/gcc/cp/parser.c\n@@ -10419,6 +10419,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)\n   tree exception_spec = NULL_TREE;\n   tree template_param_list = NULL_TREE;\n   tree tx_qual = NULL_TREE;\n+  tree return_type = NULL_TREE;\n   cp_decl_specifier_seq lambda_specs;\n   clear_decl_specs (&lambda_specs);\n \n@@ -10493,8 +10494,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)\n       if (cp_lexer_next_token_is (parser->lexer, CPP_DEREF))\n         {\n           cp_lexer_consume_token (parser->lexer);\n-          LAMBDA_EXPR_RETURN_TYPE (lambda_expr)\n-\t    = cp_parser_trailing_type_id (parser);\n+          return_type = cp_parser_trailing_type_id (parser);\n         }\n \n       /* The function parameters must be in scope all the way until after the\n@@ -10517,8 +10517,8 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)\n     void *p;\n \n     clear_decl_specs (&return_type_specs);\n-    if (LAMBDA_EXPR_RETURN_TYPE (lambda_expr))\n-      return_type_specs.type = LAMBDA_EXPR_RETURN_TYPE (lambda_expr);\n+    if (return_type)\n+      return_type_specs.type = return_type;\n     else\n       /* Maybe we will deduce the return type later.  */\n       return_type_specs.type = make_auto ();\n@@ -10558,7 +10558,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr)\n \tDECL_ARTIFICIAL (fco) = 1;\n \t/* Give the object parameter a different name.  */\n \tDECL_NAME (DECL_ARGUMENTS (fco)) = get_identifier (\"__closure\");\n-\tif (LAMBDA_EXPR_RETURN_TYPE (lambda_expr))\n+\tif (return_type)\n \t  TYPE_HAS_LATE_RETURN_TYPE (TREE_TYPE (fco)) = 1;\n       }\n     if (template_param_list)\n@@ -10648,7 +10648,7 @@ cp_parser_lambda_body (cp_parser* parser, tree lambda_expr)\n        nor a deducible form, errors should be reported for return statements\n        in the body.  Since we used void as the placeholder return type, parsing\n        the body as usual will give such desired behavior.  */\n-    if (!LAMBDA_EXPR_RETURN_TYPE (lambda_expr)\n+    if (is_auto (TREE_TYPE (TREE_TYPE (fco)))\n         && cp_lexer_peek_nth_token (parser->lexer, 1)->keyword == RID_RETURN\n         && cp_lexer_peek_nth_token (parser->lexer, 2)->type != CPP_SEMICOLON)\n       {\ndiff --git a/gcc/cp/pt.c b/gcc/cp/pt.c\nindex aaae06d..e064a11 100644\n--- a/gcc/cp/pt.c\n+++ b/gcc/cp/pt.c\n@@ -17979,9 +17979,6 @@ tsubst_copy_and_build (tree t,\n \t   declaration of the op() for later calls to lambda_function.  */\n \tcomplete_type (type);\n \n-\tif (tree fn = lambda_function (type))\n-\t  LAMBDA_EXPR_RETURN_TYPE (r) = TREE_TYPE (TREE_TYPE (fn));\n-\n \tLAMBDA_EXPR_THIS_CAPTURE (r) = NULL_TREE;\n \n \tinsert_pending_capture_proxies ();\ndiff --git a/gcc/cp/ptree.c b/gcc/cp/ptree.c\nindex 24efe27..50c717e 100644\n--- a/gcc/cp/ptree.c\n+++ b/gcc/cp/ptree.c\n@@ -204,8 +204,6 @@ cxx_print_lambda_node (FILE *file, tree node, int indent)\n   fprintf (file, \"] \");\n   print_node (file, \"capture_list\", LAMBDA_EXPR_CAPTURE_LIST (node), indent + 4);\n   print_node (file, \"this_capture\", LAMBDA_EXPR_THIS_CAPTURE (node), indent + 4);\n-  print_node (file, \"return_type\", LAMBDA_EXPR_RETURN_TYPE (node), indent + 4);\n-  print_node (file, \"closure\", LAMBDA_EXPR_CLOSURE (node), indent + 4);\n }\n \n void\ndiff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c\nindex 869ebad..06ad203 100644\n--- a/gcc/cp/semantics.c\n+++ b/gcc/cp/semantics.c\n@@ -9304,12 +9304,6 @@ apply_deduced_return_type (tree fco, tree return_type)\n   if (return_type == error_mark_node)\n     return;\n \n-  if (LAMBDA_FUNCTION_P (fco))\n-    {\n-      tree lambda = CLASSTYPE_LAMBDA_EXPR (current_class_type);\n-      LAMBDA_EXPR_RETURN_TYPE (lambda) = return_type;\n-    }\n-\n   if (DECL_CONV_FN_P (fco))\n     DECL_NAME (fco) = make_conv_op_name (return_type);\n \n","prefixes":[]}