From patchwork Tue Mar 7 09:07:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 65332 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2324874wrd; Tue, 7 Mar 2023 01:08:04 -0800 (PST) X-Google-Smtp-Source: AK7set/B2QbXpooLyt0YRhj25CGKGU1NF7DOqtuBrjDnx3wpOh3x6xM/O0qMoMIe+NVl23zWULtQ X-Received: by 2002:a05:6402:792:b0:49e:4786:a0e2 with SMTP id d18-20020a056402079200b0049e4786a0e2mr12358411edy.14.1678180084053; Tue, 07 Mar 2023 01:08:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678180084; cv=none; d=google.com; s=arc-20160816; b=K2n5eQ5AY+JhHj2EeiG7hXESmNp04fWzD9/a8hqKBoqK6/wUF1kBUGdAlBJKtWQLws PzOLmkT37AxBRfnRzUovXq6o4E1npXDs3uBY6Cz6flS5LOIrIadYZrSb51xXAl7/+KAK kjFLXnTGAPh74BNeNPenSDMjqjj66NbLXJOc27/HJzvJj95mB5a2imVHdyLFiBF0Xjw+ HroqoZvZy7hM7gUduO50FERdEz+jlFK+dfSaaIUM48rDoFq2BQO26M97r1YU/9HV7brY 0FoibLXGKKhFyx48ywvdRd4QHwWK0S6V1KVAlEU1csQ3vpWLoNJgJ8rGNxYk7qiwsKww 6Hjg== 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-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=qF8ESQ5Kk/8bdblVmLWxJcYqV8fSEKAVOTqgUux9W/s=; b=dGTmTungc0DKFG7WeFff3JW4WLmc8IIT6Yw55RRxhdfEMSmSjk39jQunEQdh+54DCO X1RMT9i1nDyY0kF6uHnTLtD3vupL2843+NCoOVoenhCeULPGpX6DJeq6zDh4x+VPDi2C ekyyVvb6fxp7cbMbrzShvWZHcAk8IfmfIAKjlprtTLAOJ1Z1+DJX3OpkymnHD2vnnEQH XNbAy40WYSRyxlFFfA9wrsBb4M1c59TKXlc5FDhxWg2+lL42FE+adTIDf6ffvQNcIJ3W mELIc69AEhAj0KNiMqW88kHEreZDbYIokSxsRviXK6H7sXGAqX6lWmUAkCAktvJsYhZK JkEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=rRHEbIFW; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id by7-20020a0564021b0700b004c12b7f5a48si8440616edb.177.2023.03.07.01.08.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 01:08:04 -0800 (PST) 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=rRHEbIFW; 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 20F3B3858C20 for ; Tue, 7 Mar 2023 09:08:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 20F3B3858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678180083; bh=qF8ESQ5Kk/8bdblVmLWxJcYqV8fSEKAVOTqgUux9W/s=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=rRHEbIFWkkp3e9j4WOo9j92eVz8JOWb0LeUeG8FQYY7ceKPPkREbOWd9tA+lFa1NC lia6QMZAXPKd4XlOA8GtoAsHt0J0kOOqoBNHbhqVZjNDdgYIGSkAZfyj7394gtev7P LNABxbCwCLPW2W6NVTggGBcAxyjMSZH3Y7jH5/QI= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id DA568385B517 for ; Tue, 7 Mar 2023 09:07:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DA568385B517 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-dnqIVgPKNnug9LAr0CnM3A-1; Tue, 07 Mar 2023 04:07:15 -0500 X-MC-Unique: dnqIVgPKNnug9LAr0CnM3A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B3E473810B0D for ; Tue, 7 Mar 2023 09:07:14 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6E861401B290; Tue, 7 Mar 2023 09:07:14 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 32797BYo2656627 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 7 Mar 2023 10:07:12 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 32797BV32656626; Tue, 7 Mar 2023 10:07:11 +0100 Date: Tue, 7 Mar 2023 10:07:11 +0100 To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Fix up ICE in emit_support_tinfo_1 [PR109042] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek 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?1759699359662707628?= X-GMAIL-MSGID: =?utf-8?q?1759699359662707628?= Hi! In my recent rtti.cc change I assumed when emitting the support tinfos that the tinfos for the fundamental types haven't been created yet. Normally (in libsupc++.a (fundamental_type_info.o)) that is the case, but as can be seen on the testcase, one can violate it by using typeid etc. in the same TU and do it before ~__fundamental_type_info () definition. The following patch fixes that by popping from unemitted_tinfo_decls only in the normal case when it is there, and treating non-NULL DECL_INITIAL on a tinfo node as indication that emit_tinfo_decl has processed it already. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-03-07 Jakub Jelinek PR c++/109042 * rtti.cc (emit_support_tinfo_1): Don't assert that last unemitted_tinfo_decls element is tinfo, instead pop from it only in that case. * decl2.cc (c_parse_final_cleanups): Don't call emit_tinfo_decl for unemitted_tinfO_decls which have already non-NULL DECL_INITIAL. * g++.dg/rtti/pr109042.C: New test. Jakub --- gcc/cp/rtti.cc.jj 2023-03-03 00:34:52.028567946 +0100 +++ gcc/cp/rtti.cc 2023-03-06 19:06:27.433307136 +0100 @@ -1581,10 +1581,10 @@ emit_support_tinfo_1 (tree bltn) /* Emit it right away if not emitted already. */ if (DECL_INITIAL (tinfo) == NULL_TREE) { - gcc_assert (unemitted_tinfo_decls->last () == tinfo); bool ok = emit_tinfo_decl (tinfo); gcc_assert (ok); - unemitted_tinfo_decls->pop (); + if (unemitted_tinfo_decls->last () == tinfo) + unemitted_tinfo_decls->pop (); } } } --- gcc/cp/decl2.cc.jj 2023-01-18 16:11:47.053213397 +0100 +++ gcc/cp/decl2.cc 2023-03-06 19:07:16.830582984 +0100 @@ -4982,7 +4982,7 @@ c_parse_final_cleanups (void) get emitted. */ for (i = unemitted_tinfo_decls->length (); unemitted_tinfo_decls->iterate (--i, &t);) - if (emit_tinfo_decl (t)) + if (DECL_INITIAL (t) || emit_tinfo_decl (t)) { reconsider = true; unemitted_tinfo_decls->unordered_remove (i); --- gcc/testsuite/g++.dg/rtti/pr109042.C.jj 2023-03-06 19:11:06.995208812 +0100 +++ gcc/testsuite/g++.dg/rtti/pr109042.C 2023-03-06 19:10:59.117324298 +0100 @@ -0,0 +1,20 @@ +// PR c++/109042 +// { dg-do compile } + +namespace std { class type_info {}; } + +std::type_info +foo () +{ + return typeid (void); +} + +namespace __cxxabiv1 { + struct __fundamental_type_info { + virtual ~__fundamental_type_info (); + }; + + __fundamental_type_info::~__fundamental_type_info () + { + } +}