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: 1677077 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=YZhYym7i; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MRHDj4FRMz1yny for ; Tue, 13 Sep 2022 05:47:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3D0713850840 for ; Mon, 12 Sep 2022 19:47:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D0713850840 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663012035; bh=VJ3RV0oOdK+UVRipVDLWAa4zxDol2glvEs31mrukbM4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=YZhYym7iRH+VJabGftw9nxuD2OeBhlHyPSSaQtlC7iOmDokrFECvkxRRQSuFh1FR7 RigR0wJgaUSJSQFS+8oLSMnAXyaEgeW/zEWfQMdZgDlKuKUWXLhpI/LYE07VSRlaA/ dHfQFJtk01pBpWXGWv5p0ZvKommdx7hHb2VFu42E= 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-Google-Smtp-Source: AA6agR7UTE/Uen1vqXlPacxauCQdsQTW5HOvND66VGziQi5UbJ/jhGknaIqPWtgCqjelKUIyxJMcdA== 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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;