From patchwork Mon Sep 12 19:46:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1174 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp2027103wrt; Mon, 12 Sep 2022 12:48:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR71mXUhKJ6NS7JUdg8WAJQhNMHD0GWqGi8Au3WXQ3Gts/jdOszYSS0U9lGpoEVOz8+hZ5km X-Received: by 2002:aa7:cf19:0:b0:44f:dc1:fc7c with SMTP id a25-20020aa7cf19000000b0044f0dc1fc7cmr22898910edy.353.1663012089345; Mon, 12 Sep 2022 12:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663012089; cv=none; d=google.com; s=arc-20160816; b=lLiZ/B/ey1a7yZqhJCeVYLAxRx7kYVY/pArpR6sieusMQxIAjhggc9jKJc4q+v+7ir YNGtN88EBf7uIj9yf/vfxj1iPv+dqnMFVg3dvsKJHFpPwYjy68qck3rCvwAOUNYFCyr/ bQJpJai0FkBdzIPRtDCjgnVUSA44NveXkc1akFsunGXraSeflLovLUD+iZkvm9TNV2xQ I1MetXWPcN+p37B+XUAuV7ZSZEzX+FLGn+MT5dtSO6X6gSPwfpL71D7pKwPalLQunlOB aID/ui5wfzDvNRqUfnBC5htIlRcOXNA0jkAePTxCkv7O+aLWe14ZweSDYny5PqgnnU29 L07w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=VJ3RV0oOdK+UVRipVDLWAa4zxDol2glvEs31mrukbM4=; b=mk7fZ7TBgkktZkHfmDQLULCyLfPd0/hCElpqjIJ0uvMymkxtnfBwpthFyG0Vpvyt2t BJi2lT+Id9Dt7gT+3kUL5puTPCn7acX9odCzKgMH6Zv0cJy2/gW0N1StpG04McyeFacZ OwOEfA8nZrCrWDb65TMXS1taZNSnmLzjVL/Ze9UOMxjar6wy68Q7nBI/p9nGDOaWRlze 59duEA/d6e7uCUQVroTC6B6c7hfznqjFJYOjNsH0SgMBoAx4Uv729yRrJLT/Q3woztiB zOOS6iD2iq8S1Bijqv9odzZ3rim8pRjfqJoB8kEgkGgk9v6urnteBeMCCeurJj9a6TLy 4iCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=J2Io76br; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id y20-20020a056402271400b00451b5bd95c6si3225900edd.549.2022.09.12.12.48.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 12:48:09 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=J2Io76br; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6D17A3850871 for ; Mon, 12 Sep 2022 19:47:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D17A3850871 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663012059; bh=VJ3RV0oOdK+UVRipVDLWAa4zxDol2glvEs31mrukbM4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=J2Io76brUxQ4aUHo67iNsPnKuyhdA1oWQnLb3dN3hfQR1gXGXmD6eDGmFxw4mP4X+ BLmgXPIS2X2TQ3iJid4S0N7V0NpHpH5BQ1E5rT3a6xCHvhj/H97VCbJTmllXuULdhz XQ0gvQ2cWoIgkwW1SFnJuNpRK75jT4t2wSWUbeEc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 4ADF73856DE0 for ; Mon, 12 Sep 2022 19:46:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4ADF73856DE0 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-60-azJIBIf7NFGIBGFgtoIxGA-1; Mon, 12 Sep 2022 15:46:52 -0400 X-MC-Unique: azJIBIf7NFGIBGFgtoIxGA-1 Received: by mail-qt1-f200.google.com with SMTP id cd8-20020a05622a418800b0035bb00c5aaaso4076234qtb.7 for ; Mon, 12 Sep 2022 12:46:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date; bh=VJ3RV0oOdK+UVRipVDLWAa4zxDol2glvEs31mrukbM4=; b=MxeC0y8xF55XXX5XZ4WhZR1NeUqKbYYPqn+FzZG/NkT7vQfUcm0T6ar1Bo/CFzNDf7 gmqE6Jnd+eSKBUnQQ/WOTRFw3zpdUTXZF0ANIxd+FakA0nvztLUfBBMmZygAfxWWOMAa bSaJR0xdwEvk0wwg56YcBhfKE1QwMHYUdsjacl4b6/+qtjmqk3Yh3g1oxxt+eyiaqkJd gHmZel4Q+i+dBVggFlOvqFh3tlWZJd3FwJsVt94Pte2Oh2a8Q3mschM+5lKnBTdOHSXZ 8RgZCwpLGZJqEH/GVHeDM3qR47NNo5BayaCZ+SjoKQGaqITEGIX2A3SwhuNXM6dwpr5e Ahpw== X-Gm-Message-State: ACgBeo2In2BYh5SKK4hnEBAm6sFO/aObhQsPKYgcNYlD/47/eJB3yZzy xkCzvoou2lURM1DSDgHNlXq4VicA2c1IYVqUHTnxGgdK+v0/8Cyr1N/xQ/YgMi5h6EkqO1N3ZjH Mm6MrlTeeRwRgZnuPtMqftYj80ajlJuBtfM6uVnc1XtDO9sWKSH9CGAWKqXCA0OW0WQ== X-Received: by 2002:ad4:5dea:0:b0:4ac:6ffc:74b2 with SMTP id jn10-20020ad45dea000000b004ac6ffc74b2mr21608939qvb.78.1663012011976; Mon, 12 Sep 2022 12:46:51 -0700 (PDT) X-Received: by 2002:ad4:5dea:0:b0:4ac:6ffc:74b2 with SMTP id jn10-20020ad45dea000000b004ac6ffc74b2mr21608904qvb.78.1663012011423; Mon, 12 Sep 2022 12:46:51 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id o7-20020a05620a228700b006b95f832aebsm793148qkh.96.2022.09.12.12.46.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 12:46:50 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: auto member function and auto variable [PR106893] Date: Mon, 12 Sep 2022 15:46:46 -0400 Message-Id: <20220912194646.3441845-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743794564225272679?= X-GMAIL-MSGID: =?utf-8?q?1743794564225272679?= As with PR105623, we need to call mark_single_function sooner to resolve the type of a BASELINK. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/106893 PR c++/90451 gcc/cp/ChangeLog: * decl.cc (cp_finish_decl): Call mark_single_function. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/auto-fn65.C: New test. --- gcc/cp/decl.cc | 3 +++ gcc/testsuite/g++.dg/cpp1y/auto-fn65.C | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/auto-fn65.C base-commit: 7c989a8ed47228bdd494a2f0d1f6fdd325f953d7 prerequisite-patch-id: cc4d1e7bcdd804ea5a1a64ea9a138d9279e5eaa8 diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 4665a29a24d..88f283bc4bd 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -8140,6 +8140,9 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, d_init = build_x_compound_expr_from_list (d_init, ELK_INIT, tf_warning_or_error); d_init = resolve_nondeduced_context (d_init, tf_warning_or_error); + /* Force auto deduction now. Use tf_none to avoid redundant warnings + on deprecated-14.C. */ + mark_single_function (d_init, tf_none); } enum auto_deduction_context adc = adc_variable_type; if (DECL_DECOMPOSITION_P (decl)) diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn65.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn65.C new file mode 100644 index 00000000000..78bb004303b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/auto-fn65.C @@ -0,0 +1,10 @@ +// PR c++/106893 +// { dg-do compile { target c++14 } } + +template +struct CoordTraits +{ + static auto GetX(T const &p) { return 1; } +}; +typedef CoordTraits Traits; +static constexpr auto GetX = Traits::GetX;