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: 90269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp59155vqo; Thu, 4 May 2023 18:08:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7l/Ct9jPI/uchY2rdcdrQhXtan/pkykJZpVL5/Kn+DJhJlJqQa9+dbN3tUBPz894eS9Phk X-Received: by 2002:aa7:dc10:0:b0:50b:c56a:feec with SMTP id b16-20020aa7dc10000000b0050bc56afeecmr2728635edu.17.1683248890001; Thu, 04 May 2023 18:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683248889; cv=none; d=google.com; s=arc-20160816; b=ZyXDr06NS1wQoVYBIWJ4BN6GipqyDEs0wpHUD336BpPiKXE2VyZhw5/EITwDY20nQg NNkN2ZfPBGTccsOroSUuIJAI1zzsSPuCWior+Cv+VEYzksxWN/fnZAcWBdjU+QxTZ+BP rKsUDpYAqtN28JC60IqagLAIzrX4/PDJBPjxQ2DnLD5vi8Ifx0Nzfjr0Gwsm6Ib3ZtSv gu6Lat221AdwCvGqxOREh9S7lk4bpZY1i9ZlIhwbm2C8+skvgDDLzD6O/BDJbfDSpOHQ U+4JFAD8hbyL0R4+rbJuPh/lQHdDTMFd4W0KwARkA+p3UnrUQnFe9DDR3fFSSw+4ENUv ztbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=136MMjebzYEV1PGiz04qMGYFSp40lc10HQ578YRLu+o=; b=pkWk4vdaHOw7148hqUa9gDNSB7vhb3jZ7QkUjFkRMuObc/ibImRT3CNGH55fja3iij hDTWW3OSuAILMJV3boH12/RDRwR/XN4tXfLOsyj7yXyzIm51FRnmIdB7hQ6DlKkzd5X2 xIXskj6PTtZmovCpnGRvsNUfZRZML0Wet1J8u57/gHbpq3F8+mGWVwyoNB/KZn7agLM7 +reMv4jO6l/VuMrj0K8kGbIq93R2pIqMSN1blzwxxNeQYNiY1XIOG+h1bMxUoqss6aX5 Yt7q9oE+3ngRj/mmzGeo8UOPbBcEWuDVeSy/PqcwQ3Sko1dLVghfpOsW6Y/pOtMnGWDf B8sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gDYhzvuP; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i12-20020aa7dd0c000000b005068241f4b7si3813623edv.483.2023.05.04.18.08.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 18:08:09 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gDYhzvuP; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A32C23856965 for ; Fri, 5 May 2023 01:08:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A32C23856965 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683248880; 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=gDYhzvuPY+MVSqY2YoOm6JLS2kPb5LU9QqotwMbWd1gSl1rDUjbc/sq6zMfrjjj+x gYSXPga/unObDBmAAcz46CiKHSuNb4N+FT7bfzdpPJN0m+8wZsay+W9lJ4eZpxsAkk bbQ3V8L596VQDJiVY0iULiRr1Dv4jjC2F+cfKhPw= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765014388437771445?= X-GMAIL-MSGID: =?utf-8?q?1765014388437771445?= 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); }