From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2E795388F40D; Tue, 5 May 2020 14:19:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E795388F40D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588688390; bh=G5Er6NJXq5iCpIM65HJC658+9ogdYO5/ov08T86D19M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=es2Uvv0VfNW6zsOrhNqLDJCiUCHWbquHeJW8yt/zqIt346PtfcjDx8j4IoBnJe3w8 4jO+JA+d6ESlwUDCa51Un10b29E829mPVwZIBho+LCeEBpu/uJbU22HLhtpvNd5LIL Cv9O9qZrbMfu5hTnPcBkEV2Cm9F7qP2MyuoCgi5c= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94799] [8/9/10/11 Regression] Calling a member template function fails Date: Tue, 05 May 2020 14:19:50 +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: 9.3.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: P2 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: 8.5 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, 05 May 2020 14:19:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94799 --- Comment #7 from CVS Commits --- The master branch has been updated by Marek Polacek : https://gcc.gnu.org/g:ef3479afc5ab415f00a53fc6f6a990df7f6a0747 commit r11-86-gef3479afc5ab415f00a53fc6f6a990df7f6a0747 Author: Marek Polacek Date: Tue Apr 28 22:30:44 2020 -0400 c++: Member template function lookup failure [PR94799] Whew, this took a while. We fail to parse "p->template A::a()" (where p is of type A *) because since r249752 we treat the RHS of t= he -> as dependent and avoid a lookup in the enclosing context: since that rev cp_parser_template_name checks parser->context->object_type too, which here is unknown_type_node, signalling a type-dependent object: 7756 if (dependent_p) 7757 /* Tell cp_parser_lookup_name that there was an object, even though it's 7758 type-dependent. */ 7759 parser->context->object_type =3D unknown_type_node; with which cp_parser_template_name returns identifier 'A', cp_parser_class_name then creates a TEMPLATE_ID_EXPR A, but then 23735 decl =3D make_typename_type (scope, decl, tag_type, tf_erro= r); in cp_parser_class_name fails because scope is NULL. Then we return error_mark_node and parse errors ensue. I've tried various approaches, e.g. keeping TEMPLATE_ID_EXPR around instead of calling make_typename_type, which didn't work, whereupon I realized that since we don't want to perform name lookup if we've seen the template keyword and the scope is dependent, we can adjust parser->context->object_type and use the type of the object expression as the scope, even if it's type-dependent. This should be in line with [basic.lookup.classref]p4. If the postfix expression doesn't have a ty= pe, use typeof to carry its type. This typeof will be processed in tsubst/TYPENAME_TYPE. PR c++/94799 * parser.c (cp_parser_postfix_dot_deref_expression): If we have a type-dependent object of class type, stash it to parser->context->object_type. If the postfix expression doesn't have a type, use typeof. (cp_parser_class_name): Consider object scope too. (cp_parser_lookup_name): Remove code dealing with the case when object_type is unknown_type_node. * g++.dg/lookup/this1.C: Adjust dg-error. * g++.dg/template/lookup12.C: New test. * g++.dg/template/lookup13.C: New test. * g++.dg/template/lookup14.C: New test. * g++.dg/template/lookup15.C: New test.=