From patchwork Thu Jan 20 03:41:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 50256 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7A3483857C77 for ; Thu, 20 Jan 2022 03:42:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A3483857C77 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1642650157; bh=Zxc68KZp8p/RF7N4oBW0CaKWhQhw/4e1xmsIhDHKrJU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GjcSPipH7izQZZgSpBXToQA7lRszUgNnjqFSug0V0qfuNALzdqlr+wrkM8DvfQDea Ts6coNmw5vrqkxTdaL16nmvo86uAJ1zsRBWZQP16K7hU0IXfeLhen00o3tcG7TCdwg Mtq6QFl6dq4WGR575PZ9i12im4G95V7WHpRwYogI= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 66C8C385841D for ; Thu, 20 Jan 2022 03:42:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 66C8C385841D Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-203-qe4sDnJzOyWoOpGncy4Tqw-1; Wed, 19 Jan 2022 22:42:02 -0500 X-MC-Unique: qe4sDnJzOyWoOpGncy4Tqw-1 Received: by mail-qk1-f197.google.com with SMTP id 22-20020a05620a06d600b0047a27f4b358so3622004qky.3 for ; Wed, 19 Jan 2022 19:42:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Zxc68KZp8p/RF7N4oBW0CaKWhQhw/4e1xmsIhDHKrJU=; b=HhiW2HKdKoYNp9wD1hw9YPV7m5+chD3CmcBTfFDdciuzKreJVL7t/6407o2MWTEK1L ogW+ZMqVa/d6w70k1tfrwRL0j7IAyuYk5GgSMb1L+41YXuXtv5ZwuFqtTR9zIY9CVIdC MXgYqqxBtZ3Hqt4gaI52GHiqgO3j+n+l7ayWr3FRyWSS1DpJieYKpURJro2RQIex+EtD HvleRu20lFjS2X6YEXJYNQCAhc0dctWbULotMNIDvYCNgG0AsEWJQv3bgJsDErIhXrQM pDU7xaEg+DZVnuvFdtnIEd4YaT9uWUYIOAuVqcPKM7Z2NT1pGdca9isMsKmxuv7TKIS4 qUDA== X-Gm-Message-State: AOAM533x5O+SBir21vfD8BNLj7c24rb670qOxeLA3Ra0b+0hkE5SPrnd bvgzvKuGqpH12F9Vdi/MepBAQaOJN+wnDj80yVDz+76DIvkuYX3oHpefhn3Sgquv5DcXia+xjsg FE/itTxD890J5MOXjlZfkC/Su9VVWy/Tw8RYnw828IYEc11g7mQ+g0BK03m0+E1Nw2w== X-Received: by 2002:a05:622a:1048:: with SMTP id f8mr16704792qte.542.1642650121280; Wed, 19 Jan 2022 19:42:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfC7wse6W/yRoupDsBYZrDtX5ggWOzuLZQXYN5O0L7/QKNxcWSXJTAwt/0EqEVI6+OC/v6Yw== X-Received: by 2002:a05:622a:1048:: with SMTP id f8mr16704784qte.542.1642650120883; Wed, 19 Jan 2022 19:42:00 -0800 (PST) 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 v6sm822551qtk.88.2022.01.19.19.41.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 19:41:59 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: template-id with current inst qualifier [PR102300] Date: Wed, 19 Jan 2022 22:41:58 -0500 Message-Id: <20220120034158.336397-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.4 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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The patch for PR41723 properly changed one place to look into the current instantiation; now we need to fix this place as well. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/102300 gcc/cp/ChangeLog: * parser.cc (cp_parser_template_name): Use dependent_scope_p. gcc/testsuite/ChangeLog: * g++.dg/template/nested7.C: New test. --- gcc/cp/parser.cc | 8 ++++---- gcc/testsuite/g++.dg/parse/no-typename1.C | 2 +- gcc/testsuite/g++.dg/template/nested7.C | 12 ++++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/nested7.C base-commit: 64655e7bdbea6b922f1f759eb9f1730b5e57029f diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 00279c43404..ed219d79dc9 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -18574,7 +18574,7 @@ cp_parser_template_name (cp_parser* parser, : parser->context->object_type); if (scope && TYPE_P (scope) && (!CLASS_TYPE_P (scope) - || (check_dependency_p && dependent_type_p (scope)))) + || (check_dependency_p && dependent_scope_p (scope)))) { /* We're optimizing away the call to cp_parser_lookup_name, but we still need to do this. */ @@ -18667,9 +18667,9 @@ cp_parser_template_name (cp_parser* parser, found = true; } - /* "in a type-only context" */ + /* "that follows the keyword template"..."in a type-only context" */ if (!found && scope - && tag_type != none_type + && (template_keyword_p || tag_type != none_type) && dependentish_scope_p (scope) && cp_parser_nth_token_starts_template_argument_list_p (parser, 1)) found = true; @@ -18680,7 +18680,7 @@ cp_parser_template_name (cp_parser* parser, cp_parser_error (parser, "expected template-name"); return error_mark_node; } - else if (decl == error_mark_node) + else if (!DECL_P (decl) && !is_overloaded_fn (decl)) /* Repeat the lookup at instantiation time. */ decl = identifier; } diff --git a/gcc/testsuite/g++.dg/parse/no-typename1.C b/gcc/testsuite/g++.dg/parse/no-typename1.C index 711c621e26a..f40ea0ec13c 100644 --- a/gcc/testsuite/g++.dg/parse/no-typename1.C +++ b/gcc/testsuite/g++.dg/parse/no-typename1.C @@ -6,6 +6,6 @@ template struct A { template struct B { - A::template B foo(); // { dg-error "" "" { target c++17_down } } + A::template B foo(); }; }; diff --git a/gcc/testsuite/g++.dg/template/nested7.C b/gcc/testsuite/g++.dg/template/nested7.C new file mode 100644 index 00000000000..3a5930c0f31 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/nested7.C @@ -0,0 +1,12 @@ +// PR c++/102300 + +template +struct holder +{ + template struct fn {}; + + struct t1 : fn {}; // pass + struct t2 : holder::fn {}; // fail + struct t3 : holder::template fn {}; // fail + struct t4 : holder::template fn {}; // pass +};