From patchwork Fri May 5 01:07:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1777252 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=eDSuS17k; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QCCGP3Dsdz1ydV for ; Fri, 5 May 2023 11:07:40 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0B4B23857702 for ; Fri, 5 May 2023 01:07:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B4B23857702 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683248856; bh=136MMjebzYEV1PGiz04qMGYFSp40lc10HQ578YRLu+o=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=eDSuS17k8HdYOwM8xklnLdA2dpUwwBmXdDPm1ueVRLbt2xthSfSi5vF/vF9MAGWyy oCTTX80b54nXfQp49KjoVm3GOsJaQ5Ori6I/+ryoZ89yLVUCGLcBh2Lus2V//gQPsS sbIYPrLu4GlP7mTzw+nTc3JZlmHlxZc4Fm2gOAA8= 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 B5ABF3858D33 for ; Fri, 5 May 2023 01:07:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B5ABF3858D33 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-113-6_FHkIyhPpWfsrtn5qAU0A-1; Thu, 04 May 2023 21:07:12 -0400 X-MC-Unique: 6_FHkIyhPpWfsrtn5qAU0A-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-3f060b8b39cso6066981cf.2 for ; Thu, 04 May 2023 18:07:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683248832; x=1685840832; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=136MMjebzYEV1PGiz04qMGYFSp40lc10HQ578YRLu+o=; b=S/RP45Q+yTU67mVIU6eFNAKHYhMlwuPieD0b7usggcmeDxyO8f5iawI/9ffXgMA3/6 xnyPhCiEZ2w8uYJNCIERAZLZa1gB+WWxvL6S1BZXT1YvfFzXvip2ye6v1m/sIwaec49+ 3s/HFD/5N5uz+JtE71785S1kR+MuCbDAqHXhq0zqmZBZnPRkccKI8sqOUosS7Ivcd3qe p76sa7JbSCOPsrpv6sghBI1E537VHgNMYVmk2FsNu0xfFtXz5RRf4oUjPd3ktVz9NUyl CQflIVKrLSOMARI3rFZxfMBNGlPzu320/asY80w39SIjHbQVDaWJw3rfCwG+3dkd8cpF qPEw== X-Gm-Message-State: AC+VfDz5FGvAa3ACHnGoqVnq4G8vDX686lBG4Kz2wnWg9EfmpyLAgnQf MpveoAp+LVZP4nqi/sVzeB5K7rBVeTW9jIS+KFWXbQg6uDa0Q6p01kEkZw8FDn6BOpQubmMILLV s1151w6OQE9cd3FJx619jqac/ffdRhjFWW8ldbyHHhfAeZ4ZtYLkXzIW/l7f/4PryFasQNqpDUg == X-Received: by 2002:a05:622a:2c2:b0:3f0:ab44:5b09 with SMTP id a2-20020a05622a02c200b003f0ab445b09mr333636qtx.0.1683248832102; Thu, 04 May 2023 18:07:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ictjlQMBO+T/xvxMdunn/wllWzn/v1QYB3q3iGyXDnN0+c9dae4PNO+1fsQ/cC9dLNoSsHQ== X-Received: by 2002:a05:622a:2c2:b0:3f0:ab44:5b09 with SMTP id a2-20020a05622a02c200b003f0ab445b09mr333606qtx.0.1683248831678; Thu, 04 May 2023 18:07:11 -0700 (PDT) Received: from jason.com (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id n7-20020a05620a152700b0074e17456a87sm233711qkk.7.2023.05.04.18.07.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 18:07:11 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] Revert "c++: restore instantiate_decl assert" Date: Thu, 4 May 2023 21:07:07 -0400 Message-Id: <20230505010707.2687333-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230427014542.539011-1-jason@redhat.com> References: <20230427014542.539011-1-jason@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.0 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_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- In the testcase the assert fails because we use one member function from another while we're in the middle of instantiating them all, which is perfectly fine. It seems complicated to detect this situation, so let's remove the assert again. PR c++/109658 This reverts commit 95d4c0d2e6318aef88ba0bc607dfc1ec6b7a612f. gcc/testsuite/ChangeLog: * g++.dg/template/local10.C: New test. --- gcc/cp/pt.cc | 6 ------ gcc/testsuite/g++.dg/template/local10.C | 10 ++++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/local10.C base-commit: 4657977541de1056a1cb651d6e2ba22472f62d04 diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 5446b5058b7..0f4fb258f9e 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -27061,12 +27061,6 @@ instantiate_decl (tree d, bool defer_ok, bool expl_inst_class_mem_p) pattern_defined = ! DECL_EXTERNAL (code_pattern); } - /* Any local class members should be instantiated from the TAG_DEFN - with defer_ok == 0. */ - gcc_checking_assert (!defer_ok || !pattern_defined - || !decl_function_context (d) - || LAMBDA_TYPE_P (DECL_CONTEXT (d))); - /* We may be in the middle of deferred access check. Disable it now. */ push_deferring_access_checks (dk_no_deferred); diff --git a/gcc/testsuite/g++.dg/template/local10.C b/gcc/testsuite/g++.dg/template/local10.C new file mode 100644 index 00000000000..9a70b846ff3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/local10.C @@ -0,0 +1,10 @@ +// PR c++/109658 + +template void encode(OutputStream, int *) { + struct ValueBaseVisitor { + void visit() { encodeString(); } + void encodeString() {} + }; +} +int encode_json; +void encode_out() { encode(encode_out, &encode_json); }