From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1D7503850415; Tue, 20 Oct 2020 13:38:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D7503850415 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/97010] C++20 ADL and function templates that are not visible (P0846R0) fails on call with templated type Date: Tue, 20 Oct 2020 13:38:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: patch, rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Oct 2020 13:38:54 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97010 --- Comment #4 from CVS Commits --- The releases/gcc-10 branch has been updated by Marek Polacek : https://gcc.gnu.org/g:257bbf154cd2b83eb02c99db73537e3b8ba3a6e7 commit r10-8915-g257bbf154cd2b83eb02c99db73537e3b8ba3a6e7 Author: Marek Polacek Date: Thu Sep 10 17:27:43 2020 -0400 c++: Fix P0846 (ADL and function templates) in template [PR97010] To quickly recap, P0846 says that a name is also considered to refer to a template if it is an unqualified-id followed by a < and name lookup finds either one or more functions or finds nothing. In a template, when parsing a function call that has type-dependent arguments, we can't perform ADL right away so we set KOENIG_LOOKUP_P in the call to remember to do it when instantiating the call (tsubst_copy_and_build/CALL_EXPR). When the called function is a function template, we represent the call with a TEMPLATE_ID_EXPR; usually the operand is an OVERLOAD. In the P0846 case though, the operand can be an IDENTIFIER_NODE, when name lookup found nothing when parsing the template name. But we weren't handling this correctly in tsubst_copy_and_build. First we need to pass the FUNCTION_P argument from to , otherwise we give a bogus error. And then in we need to perform ADL. The rest of the changes is to give better errors when ADL didn't find anything. gcc/cp/ChangeLog: PR c++/97010 * pt.c (tsubst_copy_and_build) : Call tsubst_copy_and_build explicitly instead of using the RECUR mac= ro. Handle a TEMPLATE_ID_EXPR with an IDENTIFIER_NODE as its operan= d. : Perform ADL for a TEMPLATE_ID_EXPR with an IDENTIFIER_NODE as its operand. gcc/testsuite/ChangeLog: PR c++/97010 * g++.dg/cpp2a/fn-template21.C: New test. * g++.dg/cpp2a/fn-template22.C: New test. (cherry picked from commit 635072248a426c933c74ef4431e82401249b6218)=