get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/807232/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 807232,
    "url": "http://patchwork.ozlabs.org/api/patches/807232/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/CADzB+2kcoBcQtrvS8sUEd1m_y25Fo-CbPvhorNtKmM3E76hhzQ@mail.gmail.com/",
    "project": {
        "id": 17,
        "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api",
        "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+2kcoBcQtrvS8sUEd1m_y25Fo-CbPvhorNtKmM3E76hhzQ@mail.gmail.com>",
    "list_archive_url": null,
    "date": "2017-08-29T18:55:57",
    "name": "C++ PATCH to lambda in default argument of inherited constructor",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "baba22ee75123e9f7e764d24be17345a0f09fd06",
    "submitter": {
        "id": 4337,
        "url": "http://patchwork.ozlabs.org/api/people/4337/?format=api",
        "name": "Jason Merrill",
        "email": "jason@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/CADzB+2kcoBcQtrvS8sUEd1m_y25Fo-CbPvhorNtKmM3E76hhzQ@mail.gmail.com/mbox/",
    "series": [
        {
            "id": 439,
            "url": "http://patchwork.ozlabs.org/api/series/439/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=439",
            "date": "2017-08-29T18:55:57",
            "name": "C++ PATCH to lambda in default argument of inherited constructor",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/439/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/807232/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/807232/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<gcc-patches-return-461110-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-461110-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=\"fWvR1+B1\"; 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 3xhdCX6x8dz9sPk\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 04:56:39 +1000 (AEST)",
            "(qmail 57248 invoked by alias); 29 Aug 2017 18:56:31 -0000",
            "(qmail 57190 invoked by uid 89); 29 Aug 2017 18:56:30 -0000",
            "from mail-it0-f53.google.com (HELO mail-it0-f53.google.com)\n\t(209.85.214.53) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tTue, 29 Aug 2017 18:56:20 +0000",
            "by mail-it0-f53.google.com with SMTP id o132so4558016itc.1 for\n\t<gcc-patches@gcc.gnu.org>; Tue, 29 Aug 2017 11:56:20 -0700 (PDT)",
            "by 10.107.181.23 with HTTP; Tue, 29 Aug 2017 11:55:57 -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=dpYqudaA+SF8bCCVPNSDyx0D2mpc7HAm6wo5hB2sjjpxT7\n\tgK7m1wjmA+Mann5VfNF/9kK0uGLjjJlmZpWLaDt6xu3pxX9OJY45+8lnf4Vr1Mbi\n\tkWVZiT1DdXAlJBkl1P6fYYiXTKrgI+UPw9u0/lEI8/dbp+FXWTV1+HUQg7FPQ=",
        "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=FlVPs9odosVURIpCcy0o43a9VQ0=; b=fWvR1+B1kWebId4sAuvE\n\tSrijWMBKpV5MtNbt2LQJPVvBEnddGRKRZlAs86jGBMNj8gUFmb4qZIOUGOMmLB4B\n\tt1A6IvJ08I4c3Ira8tYteqyv/E6xZqvfjfGs0wiTlCNPAkL/kQtVjqK4BzB5oBKV\n\tUmL3CCCXrZ7L7UD8JBABByY=",
        "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.5 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_LOW,\n\tRCVD_IN_SORBS_SPAM autolearn=ham version=3.3.2 spammy=remembering,\n\ttmpl",
        "X-HELO": "mail-it0-f53.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=mYvnPttWkxrarQ80b/tTavFt8Fy2kQULtMahhSz8gx4=;\n\tb=lytXIEpP2wUj6Mhh8qidmwqGmiLMIoBpZTBbTmnH7lyrx371q+Gvcp42vy1gpe2uAe\n\tFRST8gJZ0tIxfSrVjkxRRQEHA4cJSb/CnroK8mBSZYzx3mCpJFZiglAgUfNE2kfcFihW\n\tD87wBoSatstihmq1gSRKnqWSksuQ17Vr8zxZh6Q76uI+/aGYhwIOQbYTzsiZiW0sUrnL\n\tthmPhSqu/L+nnG/KqFG0t3wzleWm4utuIT1UqL1MzQhLzri91pEwF6HCTrdYUjKj4WLm\n\tKvNNgX34Pf2/yBkfzFLRDtx0rFSX0vFt6vTBb+Dh/1NDdX42YHLwDVlFwK9N3waDhk8w\n\twyyg==",
        "X-Gm-Message-State": "AHYfb5hYbwcekGGhUNiWKQQ3SfD6GxuZM9e9VJ/5WPZb5O9wNRdyAgB7\tznloJ4aXDHzCzdPRSbkwd9tSUnArD7kuP60=",
        "X-Received": "by 10.36.159.194 with SMTP id c185mr5949047ite.181.1504032978300;\n\tTue, 29 Aug 2017 11:56:18 -0700 (PDT)",
        "MIME-Version": "1.0",
        "From": "Jason Merrill <jason@redhat.com>",
        "Date": "Tue, 29 Aug 2017 14:55:57 -0400",
        "Message-ID": "<CADzB+2kcoBcQtrvS8sUEd1m_y25Fo-CbPvhorNtKmM3E76hhzQ@mail.gmail.com>",
        "Subject": "C++ PATCH to lambda in default argument of inherited constructor",
        "To": "gcc-patches List <gcc-patches@gcc.gnu.org>",
        "Content-Type": "multipart/mixed; boundary=\"94eb2c08e55067a2fd0557e8f7d2\"",
        "X-IsSubscribed": "yes"
    },
    "content": "When inheriting a template constructor, we've been leaving the\ntemplate in DECL_INHERITED_CTOR rather than the appropriate\nspecialization; this leads to a crash when we try to mangle the\ncontext for a lambda in a default argument for such a function.\n\nThis patch fixes this by remembering which specialization we found in\nsynthesized_method_walk and setting DECL_INHERITED_CTOR to that.\n\nWhile I was looking at this, I noticed that the class template\nargument deduction code's use of DECL_ABSTRACT_ORIGIN was misleading;\nit refers to the constructor from which a deduction guide was\ngenerated, not an abstract version of the same function.  I've moved\nthat information to DECL_ABSTRACT_ORIGIN on the template instead,\nwhich shouldn't confuse anything because we never look at the\nDECL_ABSTRACT_ORIGIN of other templates.\n\nTested x86_64-pc-linux-gnu, applying to trunk.\ncommit 77d09e0d881bf8803fce194fcab1dcb2817adc88\nAuthor: Jason Merrill <jason@redhat.com>\nDate:   Wed Aug 16 23:53:05 2017 -0700\n\n            Fix lambdas in template default argument of inherited ctor.\n    \n            * method.c (synthesized_method_base_walk): Replace an inherited\n            template with its specialization.\n            (synthesized_method_walk): Make inheriting_ctor a pointer.\n            (maybe_explain_implicit_delete, explain_implicit_non_constexpr)\n            (deduce_inheriting_ctor, implicitly_declare_fn): Adjust.\ncommit e0530b93b54c03025774486663d9a9ed5023f066\nAuthor: Jason Merrill <jason@redhat.com>\nDate:   Tue Aug 15 15:29:58 2017 -0700\n\n            Adjust C++17 class deduction use of DECL_ABSTRACT_ORIGIN.\n    \n            * pt.c (build_deduction_guide): Set DECL_ABSTRACT_ORIGIN on the\n            template, not the function.\n            (template_guide_p): Adjust.\n\ndiff --git a/gcc/cp/pt.c b/gcc/cp/pt.c\nindex 564ffb0..6b62ee0 100644\n--- a/gcc/cp/pt.c\n+++ b/gcc/cp/pt.c\n@@ -25058,11 +25058,9 @@ template_guide_p (const_tree fn)\n   gcc_assert (deduction_guide_p (fn));\n   if (!DECL_ARTIFICIAL (fn))\n     return false;\n-  if (tree ctor = DECL_ABSTRACT_ORIGIN (fn))\n-    {\n-      tree tmpl = DECL_TI_TEMPLATE (ctor);\n-      return PRIMARY_TEMPLATE_P (tmpl);\n-    }\n+  tree tmpl = DECL_TI_TEMPLATE (fn);\n+  if (tree org = DECL_ABSTRACT_ORIGIN (tmpl))\n+    return PRIMARY_TEMPLATE_P (org);\n   return false;\n }\n \n@@ -25173,6 +25171,7 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain)\n   bool memtmpl = false;\n   bool explicit_p;\n   location_t loc;\n+  tree fn_tmpl = NULL_TREE;\n \n   if (TYPE_P (ctor))\n     {\n@@ -25198,7 +25197,7 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain)\n     {\n       ++processing_template_decl;\n \n-      tree fn_tmpl\n+      fn_tmpl\n \t= (TREE_CODE (ctor) == TEMPLATE_DECL ? ctor\n \t   : DECL_TI_TEMPLATE (ctor));\n       if (outer_args)\n@@ -25313,7 +25312,7 @@ build_deduction_guide (tree ctor, tree outer_args, tsubst_flags_t complain)\n   DECL_TEMPLATE_INFO (ded_fn) = build_template_info (ded_tmpl, targs);\n   DECL_PRIMARY_TEMPLATE (ded_tmpl) = ded_tmpl;\n   if (DECL_P (ctor))\n-    DECL_ABSTRACT_ORIGIN (ded_fn) = ctor;\n+    DECL_ABSTRACT_ORIGIN (ded_tmpl) = fn_tmpl;\n   if (ci)\n     set_constraints (ded_tmpl, ci);",
    "diff": "diff --git a/gcc/cp/method.c b/gcc/cp/method.c\nindex 809ebc8..012d02a 100644\n--- a/gcc/cp/method.c\n+++ b/gcc/cp/method.c\n@@ -1458,7 +1458,7 @@ static tree\n synthesized_method_base_walk (tree binfo, tree base_binfo, \n \t\t\t      int quals, bool copy_arg_p,\n \t\t\t      bool move_p, bool ctor_p,\n-\t\t\t      tree inheriting_ctor, tree inherited_parms,\n+\t\t\t      tree *inheriting_ctor, tree inherited_parms,\n \t\t\t      tree fnname, int flags, bool diag,\n \t\t\t      tree *spec_p, bool *trivial_p,\n \t\t\t      bool *deleted_p, bool *constexpr_p)\n@@ -1469,8 +1469,9 @@ synthesized_method_base_walk (tree binfo, tree base_binfo,\n \n   if (copy_arg_p)\n     argtype = build_stub_type (BINFO_TYPE (base_binfo), quals, move_p);\n-  else if ((inherited_binfo\n-\t    = binfo_inherited_from (binfo, base_binfo, inheriting_ctor)))\n+  else if (inheriting_ctor\n+\t   && (inherited_binfo\n+\t       = binfo_inherited_from (binfo, base_binfo, *inheriting_ctor)))\n     {\n       argtype = inherited_parms;\n       /* Don't check access on the inherited constructor.  */\n@@ -1492,6 +1493,12 @@ synthesized_method_base_walk (tree binfo, tree base_binfo,\n   if (defer != dk_no_deferred)\n     pop_deferring_access_checks ();\n \n+  /* Replace an inherited template with the appropriate specialization.  */\n+  if (inherited_binfo && rval\n+      && DECL_P (*inheriting_ctor) && DECL_P (rval)\n+      && DECL_CONTEXT (*inheriting_ctor) == DECL_CONTEXT (rval))\n+    *inheriting_ctor = DECL_CLONED_FUNCTION (rval);\n+\n   process_subob_fn (rval, spec_p, trivial_p, deleted_p,\n \t\t    constexpr_p, diag, BINFO_TYPE (base_binfo));\n   if (ctor_p &&\n@@ -1526,7 +1533,7 @@ static void\n synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p,\n \t\t\t tree *spec_p, bool *trivial_p, bool *deleted_p,\n \t\t\t bool *constexpr_p, bool diag,\n-\t\t\t tree inheriting_ctor, tree inherited_parms)\n+\t\t\t tree *inheriting_ctor, tree inherited_parms)\n {\n   tree binfo, base_binfo, fnname;\n   int i;\n@@ -1581,7 +1588,7 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p,\n     }\n \n   gcc_assert ((sfk == sfk_inheriting_constructor)\n-\t      == (inheriting_ctor != NULL_TREE));\n+\t      == (inheriting_ctor && *inheriting_ctor != NULL_TREE));\n \n   /* If that user-written default constructor would satisfy the\n      requirements of a constexpr constructor (7.1.5), the\n@@ -1656,7 +1663,7 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p,\n   tree scope = push_scope (ctype);\n \n   int flags = LOOKUP_NORMAL | LOOKUP_SPECULATIVE;\n-  if (!inheriting_ctor)\n+  if (sfk != sfk_inheriting_constructor)\n     flags |= LOOKUP_DEFAULTED;\n \n   tsubst_flags_t complain = diag ? tf_warning_or_error : tf_none;\n@@ -1770,9 +1777,9 @@ get_defaulted_eh_spec (tree decl, tsubst_flags_t complain)\n   bool const_p = CP_TYPE_CONST_P (non_reference (parm_type));\n   tree spec = empty_except_spec;\n   bool diag = !DECL_DELETED_FN (decl) && (complain & tf_error);\n+  tree inh = DECL_INHERITED_CTOR (decl);\n   synthesized_method_walk (ctype, sfk, const_p, &spec, NULL, NULL,\n-\t\t\t   NULL, diag, DECL_INHERITED_CTOR (decl),\n-\t\t\t   parms);\n+\t\t\t   NULL, diag, &inh, parms);\n   return spec;\n }\n \n@@ -1847,10 +1854,11 @@ maybe_explain_implicit_delete (tree decl)\n \t  tree raises = NULL_TREE;\n \t  bool deleted_p = false;\n \t  tree scope = push_scope (ctype);\n+\t  tree inh = DECL_INHERITED_CTOR (decl);\n \n \t  synthesized_method_walk (ctype, sfk, const_p,\n \t\t\t\t   &raises, NULL, &deleted_p, NULL, false,\n-\t\t\t\t   DECL_INHERITED_CTOR (decl), parms);\n+\t\t\t\t   &inh, parms);\n \t  if (deleted_p)\n \t    {\n \t      inform (DECL_SOURCE_LOCATION (decl),\n@@ -1858,7 +1866,7 @@ maybe_explain_implicit_delete (tree decl)\n \t\t      \"definition would be ill-formed:\", decl);\n \t      synthesized_method_walk (ctype, sfk, const_p,\n \t\t\t\t       NULL, NULL, NULL, NULL, true,\n-\t\t\t\t       DECL_INHERITED_CTOR (decl), parms);\n+\t\t\t\t       &inh, parms);\n \t    }\n \t  else if (!comp_except_specs\n \t\t   (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (decl)),\n@@ -1887,11 +1895,12 @@ explain_implicit_non_constexpr (tree decl)\n {\n   tree parm_type = TREE_VALUE (FUNCTION_FIRST_USER_PARMTYPE (decl));\n   bool const_p = CP_TYPE_CONST_P (non_reference (parm_type));\n+  tree inh = DECL_INHERITED_CTOR (decl);\n   bool dummy;\n   synthesized_method_walk (DECL_CLASS_CONTEXT (decl),\n \t\t\t   special_function_p (decl), const_p,\n \t\t\t   NULL, NULL, NULL, &dummy, true,\n-\t\t\t   DECL_INHERITED_CTOR (decl),\n+\t\t\t   &inh,\n \t\t\t   FUNCTION_FIRST_USER_PARMTYPE (decl));\n }\n \n@@ -1906,22 +1915,25 @@ deduce_inheriting_ctor (tree decl)\n   gcc_assert (DECL_INHERITED_CTOR (decl));\n   tree spec;\n   bool trivial, constexpr_, deleted;\n+  tree inh = DECL_INHERITED_CTOR (decl);\n   synthesized_method_walk (DECL_CONTEXT (decl), sfk_inheriting_constructor,\n \t\t\t   false, &spec, &trivial, &deleted, &constexpr_,\n \t\t\t   /*diag*/false,\n-\t\t\t   DECL_INHERITED_CTOR (decl),\n+\t\t\t   &inh,\n \t\t\t   FUNCTION_FIRST_USER_PARMTYPE (decl));\n   if (TREE_CODE (inherited_ctor_binfo (decl)) != TREE_BINFO)\n     /* Inherited the same constructor from different base subobjects.  */\n     deleted = true;\n   DECL_DELETED_FN (decl) = deleted;\n   TREE_TYPE (decl) = build_exception_variant (TREE_TYPE (decl), spec);\n+  SET_DECL_INHERITED_CTOR (decl, inh);\n \n   tree clone;\n   FOR_EACH_CLONE (clone, decl)\n     {\n       DECL_DELETED_FN (clone) = deleted;\n       TREE_TYPE (clone) = build_exception_variant (TREE_TYPE (clone), spec);\n+      SET_DECL_INHERITED_CTOR (clone, inh);\n     }\n }\n \n@@ -2035,12 +2047,12 @@ implicitly_declare_fn (special_function_kind kind, tree type,\n       raises = noexcept_deferred_spec;\n       synthesized_method_walk (type, kind, const_p, NULL, &trivial_p,\n \t\t\t       &deleted_p, &constexpr_p, false,\n-\t\t\t       inherited_ctor, inherited_parms);\n+\t\t\t       &inherited_ctor, inherited_parms);\n     }\n   else\n     synthesized_method_walk (type, kind, const_p, &raises, &trivial_p,\n \t\t\t     &deleted_p, &constexpr_p, false,\n-\t\t\t     inherited_ctor, inherited_parms);\n+\t\t\t     &inherited_ctor, inherited_parms);\n   /* Don't bother marking a deleted constructor as constexpr.  */\n   if (deleted_p)\n     constexpr_p = false;\n@@ -2153,7 +2165,7 @@ implicitly_declare_fn (special_function_kind kind, tree type,\n       input_location = DECL_SOURCE_LOCATION (fn);\n       synthesized_method_walk (type, kind, const_p,\n \t\t\t       NULL, NULL, NULL, NULL, true,\n-\t\t\t       NULL_TREE, NULL_TREE);\n+\t\t\t       NULL, NULL_TREE);\n       input_location = loc;\n     }\n \ndiff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle5.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle5.C\nnew file mode 100644\nindex 0000000..dd95894\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle5.C\n@@ -0,0 +1,15 @@\n+// { dg-do compile { target c++11 } }\n+// { dg-final { scan-assembler \"_ZZN1AIiEC4IiEET_S2_Ed_NKUlvE_clEv\" } }\n+\n+template <class T> struct A\n+{\n+  template <class U>\n+  A(U, U = []{ return 42; }());\n+};\n+\n+struct B: A<int>\n+{\n+  using A::A;\n+};\n+\n+B b(24);\n",
    "prefixes": []
}