From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 04C0D385843B for ; Tue, 22 Feb 2022 21:46:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 04C0D385843B Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-400-2yhqp9HLNDq_LRD1mCvdtg-1; Tue, 22 Feb 2022 16:46:27 -0500 X-MC-Unique: 2yhqp9HLNDq_LRD1mCvdtg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F15EE80D6AE for ; Tue, 22 Feb 2022 21:46:26 +0000 (UTC) Received: from pdp-11.redhat.com (unknown [10.22.9.219]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57C3EE2FA; Tue, 22 Feb 2022 21:46:24 +0000 (UTC) From: Marek Polacek To: GCC Patches , Jason Merrill Subject: [PATCH] c++: ->template and implicit typedef [PR104608] Date: Tue, 22 Feb 2022 16:46:17 -0500 Message-Id: <20220222214617.1949703-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-13.7 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, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Tue, 22 Feb 2022 21:46:34 -0000 Here we have a forward declaration of Parameter for which we create an implicit typedef, which is a TYPE_DECL. Then, when looking it up at template definition time, cp_parser_template_id gets (since r12-6754) this TYPE_DECL which it can't handle. This patch defers lookup for implicit typedefs, a la r12-6879. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? PR c++/104608 gcc/cp/ChangeLog: * parser.cc (cp_parser_template_name): Repeat lookup of implicit typedef. gcc/testsuite/ChangeLog: * g++.dg/parse/template-keyword3.C: New test. --- gcc/cp/parser.cc | 3 ++- gcc/testsuite/g++.dg/parse/template-keyword3.C | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/parse/template-keyword3.C diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 03d99aba13e..5e89e3737b0 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -18681,7 +18681,8 @@ cp_parser_template_name (cp_parser* parser, return error_mark_node; } else if ((!DECL_P (decl) && !is_overloaded_fn (decl)) - || TREE_CODE (decl) == USING_DECL) + || TREE_CODE (decl) == USING_DECL + || DECL_IMPLICIT_TYPEDEF_P (decl)) /* Repeat the lookup at instantiation time. */ decl = identifier; } diff --git a/gcc/testsuite/g++.dg/parse/template-keyword3.C b/gcc/testsuite/g++.dg/parse/template-keyword3.C new file mode 100644 index 00000000000..59fe0fc180b --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/template-keyword3.C @@ -0,0 +1,12 @@ +// PR c++/104608 + +class Parameter; +template class Function +: public R +{ + Function(); +}; +template +Function::Function() { + this->template Parameter(); +} base-commit: bc66b471d16ef2fd8cb66fd1131b41f80ecb9961 -- 2.35.1