From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id 49FD138515FD; Mon, 12 Sep 2022 19:47:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49FD138515FD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663012031; bh=r1aWQiuObmKBBVrTZ8A6D5/kONFR5tB0rmHb45Muxzs=; h=From:To:Subject:Date:From; b=AjGAqXb638zCmIXyrHF0Eu5frj+Z7suh3UTxPkYOxiTGI9BuzllT/c7Ket8DiproC Et0hRS7ee9RhB17NVd8wkJXfQxiR8HsLv6hcdZU68UISZDX6+bN7yHXfTCZX5WeiWF DJCT0bvrc2PIf6Ae7BANkUePF3Ud3Kpw9aC2JbBc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2632] c++: auto member function and auto variable [PR106893] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/master X-Git-Oldrev: 6bcca5f642eb950a3cef024ea49a35e4792306f6 X-Git-Newrev: 03381beccb52c0e2c15da3b8b8dfa3bb6eb71df9 Message-Id: <20220912194711.49FD138515FD@sourceware.org> Date: Mon, 12 Sep 2022 19:47:11 +0000 (GMT) List-Id: https://gcc.gnu.org/g:03381beccb52c0e2c15da3b8b8dfa3bb6eb71df9 commit r13-2632-g03381beccb52c0e2c15da3b8b8dfa3bb6eb71df9 Author: Jason Merrill Date: Mon Sep 12 13:47:34 2022 -0400 c++: auto member function and auto variable [PR106893] As with PR105623, we need to call mark_single_function sooner to resolve the type of a BASELINK. 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. Diff: --- gcc/cp/decl.cc | 3 +++ gcc/testsuite/g++.dg/cpp1y/auto-fn65.C | 10 ++++++++++ 2 files changed, 13 insertions(+) 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;