From patchwork Wed May 4 14:09:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 53467 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 0D4253857371 for ; Wed, 4 May 2022 14:10:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D4253857371 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1651673429; bh=Txgb2NisfZ+B/XQhvHgpQA3hI3tlC+fZcOxyuzkfdwY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kh4TAmAqaEWxc8wEXYxTV0T4eKZK/oG3mHnT7pyiPJmS25aN7xXVmy+TWQTAq+gys MyuQ1fnz6zkI5n42egf8TXDt+kURLdzxfs8GU1gM9jTbYR3A436Rbyuq6/E9MD8mKu jRwd5X2jOZnUYcw/NkudfrI46Dw+Y7VSuGrRW3gA= 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 E42D33857371 for ; Wed, 4 May 2022 14:09:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E42D33857371 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-47-qKxwHqpQNOiaan0QARD6TQ-1; Wed, 04 May 2022 10:09:58 -0400 X-MC-Unique: qKxwHqpQNOiaan0QARD6TQ-1 Received: by mail-qt1-f198.google.com with SMTP id x5-20020a05622a000500b002f37cb8b803so1024114qtw.9 for ; Wed, 04 May 2022 07:09:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Txgb2NisfZ+B/XQhvHgpQA3hI3tlC+fZcOxyuzkfdwY=; b=Fp3hWtcc91DknN/rGHKwEt1jJqcht1CaSJl7CC4uAZK0SAy5YtElZcmmfyj1OuK3ge XpRYmAAAFQayBVo5FzWd7ulx1x06H40DTpQn90VcUMAEgXbdwlfF2UcU8kGhQPMT2Kde VyhnhAUT8OhVphciRh7DdXl+Pq9WAVwOuNfngBVvKrDwwYSvw6E8AHGXOeSxa/SkSLXc zvKWEsBJlRlz/Dn/vB7iQZiMA7q6AJLnK8EJSE+hu0AfU+3AWKTFGd0fYgwK17xqM0DI T8GhknD5OSxnZTQWAJ638xEBXTEdMm5DbfJ100ZgOTD1ixG+ZIOh5w/IgQ3p0w1ziE+h EQOg== X-Gm-Message-State: AOAM530CYeatbi+xQbmyYxxkDXvFC98iISzpwoODAPskQ4slFsubOaxD uFUNyk9loATNzU0qIpoU1jHFHaTB3EtlNjtLgauH3/hAGsQ+KTFxasy5FE7I67DaQDQoA1kuLVm OEF0vbxWQz2U1nUmD28FqwzJIpNmi7s8/pHHyMAVgTZjaZUhvp46Da+GCy3PYXqOGt3g= X-Received: by 2002:a05:622a:192:b0:2f1:eb39:cfb2 with SMTP id s18-20020a05622a019200b002f1eb39cfb2mr19309590qtw.425.1651673397715; Wed, 04 May 2022 07:09:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcvyEZGzeXSbpN6xK75UDtdvj2NxtW9y3OpHdoMjtDNIhzM/HaUhLzOsPDzI47x9UCFZgVsw== X-Received: by 2002:a05:622a:192:b0:2f1:eb39:cfb2 with SMTP id s18-20020a05622a019200b002f1eb39cfb2mr19309565qtw.425.1651673397370; Wed, 04 May 2022 07:09:57 -0700 (PDT) Received: from localhost.localdomain (ool-18e40894.dyn.optonline.net. [24.228.8.148]) by smtp.gmail.com with ESMTPSA id s77-20020a37a950000000b0069ff8ebec6asm3734275qke.114.2022.05.04.07.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 May 2022 07:09:56 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: ICE during aggr CTAD for member tmpl [PR105476] Date: Wed, 4 May 2022 10:09:55 -0400 Message-Id: <20220504140955.1177342-1-ppalka@redhat.com> X-Mailer: git-send-email 2.36.0.44.g0f828332d5 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.6 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, 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-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Here we're crashing from maybe_aggr_guide ultimately because processing_template_decl isn't set when partially instantiating the guide's parameter list. This causes us to prematurely force completion of the dependent type Visitor_functior, which fails and results in an unexpected error_mark_node. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk/12.2? PR c++/105476 gcc/cp/ChangeLog: * pt.cc (maybe_aggr_guide): Set processing_template_decl when partially instantiating the guide's parameter list. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/class-deduction-aggr13.C: New test. * g++.dg/cpp2a/class-deduction-aggr13a.C: New test. --- gcc/cp/pt.cc | 6 +++++- .../g++.dg/cpp2a/class-deduction-aggr13.C | 11 +++++++++++ .../g++.dg/cpp2a/class-deduction-aggr13a.C | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13.C create mode 100644 gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13a.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index ac002907a41..2bec47dc295 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -29569,7 +29569,11 @@ maybe_aggr_guide (tree tmpl, tree init, vec *args) PARMS, so that its template level is properly reduced and we don't get mismatches when deducing types using the guide with PARMS. */ if (member_template_p) - parms = tsubst (parms, DECL_TI_ARGS (tmpl), complain, init); + { + ++processing_template_decl; + parms = tsubst (parms, DECL_TI_ARGS (tmpl), complain, init); + --processing_template_decl; + } } else if (TREE_CODE (init) == TREE_LIST) { diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13.C new file mode 100644 index 00000000000..aa8032c60b5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13.C @@ -0,0 +1,11 @@ +// PR c++/105476 +// { dg-do compile { target c++20 } } + +template struct Visitor_functor; + +template struct Events { + template struct Visitor : Visitor_functor::type_t... { }; +}; + +using ev_t = Events; +ev_t::Visitor v = { {} }; // { dg-error "too many initializers" } diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13a.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13a.C new file mode 100644 index 00000000000..69ae5dd4b60 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr13a.C @@ -0,0 +1,18 @@ +// PR c++/105476 +// { dg-do compile { target c++20 } } +// A valid version of class-deduction-aggr13.C. + +template struct Visitor_functor; + +template<> struct Visitor_functor { + using type_t = int; +}; + +template struct Events { + template struct Visitor { + Visitor_functor::type_t t; + }; +}; + +using ev_t = Events; +ev_t::Visitor v = { {} };