[{"id":1875549,"web_url":"http://patchwork.ozlabs.org/comment/1875549/","msgid":"<CADzB+2=KBXcrrxKO6mjuRJdnQtgEc3Xkh6t2RHMc89iOptZZ0A@mail.gmail.com>","list_archive_url":null,"date":"2018-03-15T03:07:15","subject":"Re: C++ PATCH for c++/81236,\n\tmissed 'this' capture with template-id in generic lambda","submitter":{"id":4337,"url":"http://patchwork.ozlabs.org/api/people/4337/","name":"Jason Merrill","email":"jason@redhat.com"},"content":"On Tue, Aug 29, 2017 at 5:37 PM, Jason Merrill <jason@redhat.com> wrote:\n> We could approach this by extending that change to all generic\n> lambdas, and that might be appropriate for GCC 7, but it seems to me\n> that this approach will just mean any problems with doing all the\n> normal processing in a template will remain latent until someone\n> happens to use them in a generic lambda; instead, this patch removes\n> the template special case and fixes the normal code to work properly\n> in templates.\n\nI noticed today that this caused a regression on the attached\ntestcases, because we weren't updating the type of the BASELINK after\ninstantiating the auto function.\n\nTested x86_64-pc-linux-gnu, applying to trunk.\ncommit d1d91f146d88b9d7442cce1e03edca55693de139\nAuthor: Jason Merrill <jason@redhat.com>\nDate:   Wed Mar 14 16:27:08 2018 -0400\n\n            PR c++/81236 - auto variable and auto function\n    \n            * pt.c (tsubst_baselink): Update the type of the BASELINK after\n            mark_used.\n\ndiff --git a/gcc/cp/pt.c b/gcc/cp/pt.c\nindex 14321816cde..2ea5fc79a2c 100644\n--- a/gcc/cp/pt.c\n+++ b/gcc/cp/pt.c\n@@ -14700,9 +14700,16 @@ tsubst_baselink (tree baselink, tree object_type,\n   /* If lookup found a single function, mark it as used at this point.\n      (If lookup found multiple functions the one selected later by\n      overload resolution will be marked as used at that point.)  */\n-  if (!template_id_p && !really_overloaded_fn (fns)\n-      && !mark_used (OVL_FIRST (fns), complain) && !(complain & tf_error))\n-    return error_mark_node;\n+  if (!template_id_p && !really_overloaded_fn (fns))\n+    {\n+      tree fn = OVL_FIRST (fns);\n+      bool ok = mark_used (fn, complain);\n+      if (!ok && !(complain & tf_error))\n+\treturn error_mark_node;\n+      if (ok && BASELINK_P (baselink))\n+\t/* We might have instantiated an auto function.  */\n+\tTREE_TYPE (baselink) = TREE_TYPE (fn);\n+    }\n \n   if (BASELINK_P (baselink))\n     {\ndiff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn48.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn48.C\nnew file mode 100644\nindex 00000000000..bf9448e793e\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn48.C\n@@ -0,0 +1,15 @@\n+// { dg-do compile { target c++14 } }\n+\n+template <class T> struct A\n+{\n+  static auto fn() { }\n+  static void f()\n+  {\n+    auto x = fn;\n+  }\n+};\n+\n+int main()\n+{\n+  A<int>::f();\n+}\ndiff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn49.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn49.C\nnew file mode 100644\nindex 00000000000..d2e490604a7\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn49.C\n@@ -0,0 +1,12 @@\n+// CWG issue 2335\n+// { dg-do compile { target c++14 } }\n+\n+template <class... Ts> struct partition_indices {\n+  static auto compute_right () {}\n+  static constexpr auto right = compute_right;\n+};\n+auto foo () -> partition_indices<>;\n+void f() {\n+  auto x = foo();\n+  auto y = x.right;\n+}","headers":{"Return-Path":"<gcc-patches-return-474758-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-474758-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=redhat.com","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"oWl6lJ5k\"; 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 401tnM2q0Bz9sVC\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 15 Mar 2018 14:07:48 +1100 (AEDT)","(qmail 48004 invoked by alias); 15 Mar 2018 03:07:40 -0000","(qmail 47948 invoked by uid 89); 15 Mar 2018 03:07:39 -0000","from mail-io0-f171.google.com (HELO mail-io0-f171.google.com)\n\t(209.85.223.171) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tThu, 15 Mar 2018 03:07:38 +0000","by mail-io0-f171.google.com with SMTP id m83so6791686ioi.8 for\n\t<gcc-patches@gcc.gnu.org>; Wed, 14 Mar 2018 20:07:38 -0700 (PDT)","by 10.107.30.9 with HTTP; Wed, 14 Mar 2018 20:07:15 -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:in-reply-to:references:from:date:message-id\n\t:subject:to:content-type; q=dns; s=default; b=owirxUYT8jPtIu/8dG\n\tt25g5GeEnctjUiwjDPwlkbfqjhmoQL4shLDZO5NvH9GwPLsSciMbzGO/I08fipa5\n\tFazHp2UD6Qnxgl/1MTWITytt+7iFVrXDrknmLqssn03hutShe8BtYKe/hNW49+dr\n\trHDuwv4UQL3FAvmdiS8zEQCqw=","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:in-reply-to:references:from:date:message-id\n\t:subject:to:content-type; s=default; bh=INXeNoFnjMQ44FANsMRAmzB6\n\trAw=; b=oWl6lJ5kKoWXLey1bA/u2LYxoOcIqPj83OeyoN2n/ZV9QN/RZk2uT/Ay\n\t9q/BxfFBPng/CScANJyq0dyL9yadrJCWmFAAFv6Anwt6gTha4jhv7AuvvE1CQKiW\n\tgNb9B+gNABDqYGGsaF0i6HWmmKVMfqSUxYqI3QIJThoQbqWWQ90=","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.6 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,\n\tRCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=","X-HELO":"mail-io0-f171.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:in-reply-to:references:from:date\n\t:message-id:subject:to;\n\tbh=jcOzCe5Z2eOzYH+fN6tlGARpBqUIyWa8H7VfFP9PbDY=;\n\tb=pTq8bU9oN1FRU7H35XqCwryDRN/gRQziOSgWBL+Txyl/rIEGSv8Etm8HsCxpWAHrdW\n\t8AlON66mnIfMnOAIAU2t5SttrN/eCcWyNbfFoJFvRTtUmX4hqGwKy/CN+HNzfZL78J6Y\n\tT22OoV3zPacZ4jcE1bHHaC74Htnf/RhJRZFqg6inV9pDGB1IBVu1Zcu/DkvcSVAKvGT2\n\tkFeePeTrrh47SR5NzSbrusmhHCJ8vfprPoCFbRQKyGFw2hYoTbOR4RR47FXM4xikvxn6\n\tYx8UcGVJdb+clScHq2RP+pJb7awT2lD9vtLj+xYHE1RP4uMy2G8jge0alP83x0Lkb1aK\n\ty1tQ==","X-Gm-Message-State":"AElRT7H3dG9TGF1o7WBV38Qe7Az6bPWMVHlYGeGg5NaHIH8seZ5JqST9\tZVJ/kPBcUlKotxhqU1lPekuDlFhRkd+pn6VoJ/FXTuxZ","X-Google-Smtp-Source":"AG47ELskujn9BRXs3jTNycPKYOG/Z9LEUDRaEVL5+jNK6efbVAFD+8HqpVCTxZQ/hgmsNcwYNSegIsbsFVZdGd8eM6g=","X-Received":"by 10.107.6.231 with SMTP id f100mr7621807ioi.23.1521083256307;\n\tWed, 14 Mar 2018 20:07:36 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<CADzB+2ntf4kfg4A0eJ7KY-i+Szj0TMud1gtptOjyNN-+FJpCNw@mail.gmail.com>","References":"<CADzB+2ntf4kfg4A0eJ7KY-i+Szj0TMud1gtptOjyNN-+FJpCNw@mail.gmail.com>","From":"Jason Merrill <jason@redhat.com>","Date":"Wed, 14 Mar 2018 23:07:15 -0400","Message-ID":"<CADzB+2=KBXcrrxKO6mjuRJdnQtgEc3Xkh6t2RHMc89iOptZZ0A@mail.gmail.com>","Subject":"Re: C++ PATCH for c++/81236,\n\tmissed 'this' capture with template-id in generic lambda","To":"gcc-patches List <gcc-patches@gcc.gnu.org>","Content-Type":"multipart/mixed; boundary=\"001a113f9be42ad9a805676acba6\"","X-IsSubscribed":"yes"}}]