From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id DE6CF385C6DA for ; Thu, 9 Nov 2023 23:29:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE6CF385C6DA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DE6CF385C6DA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::234 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699572558; cv=none; b=SSsoXRfkK9bVhaVZF3FlFr87PSRE1giuQpDcPaKHQPF9gaOXLLEco3nSH5iKJW2D7Tg7ot/iBH7273oe7WEFTEiEEE6vBhru+3H4W7bMPscGeuWi+7Qnon1iIzD/kBU+hETO09cZaYmvlBXZak+fBLQQ1YrKPB2THpctCzzExpA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699572558; c=relaxed/simple; bh=wQKHnE78mYpv7IaPomf1i8t4otbWFQS7Cya56cOUoaI=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=vp3FEA6UO6eD7et1KlZFVJK9s1IbcTx0dRF1nrzgllSfYdLI27Ccmh7Qff/ATfcmJhuIt1UcsiqzD+rSdgKm0NMgul3D5eotStDbcb+Ndad8gQSONWnGCGtsdSoWlG9uHq2hqrU3CkdDmb89gvGg9PrPuVnGKgOpOLprYXHkuTs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3b2e44c7941so806646b6e.2 for ; Thu, 09 Nov 2023 15:29:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699572556; x=1700177356; darn=gcc.gnu.org; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=a68S9W2Vuts4hiGRG7B+g0jKAJz2sanovPxuBQENogE=; b=HpmQcwpmaL5XpRsMFMLpVbJaEz1tIEtJt0pd9I5XpvQr7ZCcGQFIKAjyc4KcHhyFiC Sh5MAe/qsztm1VZAoLUy9QrCifgLoDVqDkFMF6u9ezQiXWD5qM3TH42qAdsZSdlXIMJw mbhJWeAMyxizBUyTmcmR+jSN7xOlhaj+HcTPrIB6X9Rs2VQtnYJc9fZR8lN5KgGv/JS1 pJIIWrJmcDD6Yl7L0bnjBkIQOgbmhcOty85ILMEXX/4k/zx+bOqcPr3uesTDMT+6Ezxu l7nx1ZBmAb84yJek/5yQbccHxJulvDHPa0qBfQVsbt6kXppvDC4Y4mmphCXbnF4owfZz 3miA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699572556; x=1700177356; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=a68S9W2Vuts4hiGRG7B+g0jKAJz2sanovPxuBQENogE=; b=PVcZlUUSNJb0v/M8UNzHAQv1quzMOHXva0iMztflkUcs2dBM1imCm14O1TOV79uMxF RdPkRAMh/7sfUdnsxDCOVAuqdxhxyblPrbK+ogdE4Vqi64EYrQVK4PjvQUnAtWuzb2+L msQ/t+hwNDDcnPfMxaP54313souoRaCYARZutDAkykC1Av4c+3Mtp3tjwXXpGc1xiHyk gN/9bDrJ0EcXWX44/BGGEnq33ijXsvCik1r1g0t8Zzx+yOju21/HlC+HnLm5UlYV/qiw MSJWNQC1hWKFjo96eH4I/8uKtx+/DJt8m0ITbQlB9Q6TOq4zEac2suqCXsbfbN7QwFBq 2SXQ== X-Gm-Message-State: AOJu0Yyijtn5GDLT9oqCHw1t9a6VAkbxLewv1h8LUY1winKHnPqCKrEI vcMwWO/2zj5iCpKEi8iKIfkpyycBKNk= X-Google-Smtp-Source: AGHT+IEC3XES7p+k44Xc3Iib08V/MCfJoWG9w9/yURpcB2uGPHneAz4gFIvsyRxBYD/FLiPYunc9wA== X-Received: by 2002:aca:1707:0:b0:3ae:4cad:91a0 with SMTP id j7-20020aca1707000000b003ae4cad91a0mr3338395oii.6.1699572556039; Thu, 09 Nov 2023 15:29:16 -0800 (PST) Received: from Thaum. (124-150-88-161.tpgi.com.au. [124.150.88.161]) by smtp.gmail.com with ESMTPSA id e16-20020a62ee10000000b006bf83e892e9sm11138128pfi.155.2023.11.09.15.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 15:29:15 -0800 (PST) Message-ID: <654d6b4b.620a0220.877d9.d8b2@mx.google.com> X-Google-Original-Message-ID: Date: Fri, 10 Nov 2023 10:29:11 +1100 From: Nathaniel Shead To: Nathan Sidwell Cc: gcc-patches@gcc.gnu.org, Jason Merrill Subject: Re: [PATCH] c++/modules: fix virtual destructors [PR103499] References: <654cacb3.170a0220.9f692.95e6@mx.google.com> <19c6ccd9-f3c3-416a-9124-b827bf002a07@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <19c6ccd9-f3c3-416a-9124-b827bf002a07@acm.org> X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Nov 09, 2023 at 05:57:39PM -0500, Nathan Sidwell wrote: > On 11/9/23 04:55, Nathaniel Shead wrote: > > I'm not sure if this is just papering over a general issue of clones not being > > exported/imported, or if this is just an exception to the general case of > > clones being able to be freely regenerated with no other issues. > > > > Alternatively, would it be better to override the DECL_VINDEX of the original > > declaration after filling it in for the clones as well? I wasn't able to see > > anything depending on the current behaviour (though I didn't look very hard). > > I think your patch is a fine approach. IIRC just streaming out the clones > directly ran into a bunch of issues, hence the current implementation. > > > ok > > nathan Sorry, I don't have write access, would you be able to push? Thanks. (And for my other patch.) > > > > Bootstrapped and regtexted on x86_64-pc-linux-gnu. > > > > -- >8 -- > > > > Currently, cloned functions are not included in the CMI. However, for > > virtual destructors the clones must have a different DECL_VINDEX from > > their base declaration: the former have an INTEGER_CST indicating the > > index into the vtable, while the latter indicate the FUNCTION_DECL that > > they're overriding. > > > > As such, this patch ensures that DECL_VINDEX is properly passed on for > > cloned functions as well to prevent this from causing issues. > > > > PR c++/103499 > > > > gcc/cp/ChangeLog: > > > > * module.cc (trees_out::decl_node): Write DECL_VINDEX for > > virtual clones. > > (trees_in::tree_node): Read DECL_VINDEX for virtual clones. > > > > gcc/testsuite/ChangeLog: > > > > * g++.dg/modules/pr103499_a.C: New test. > > * g++.dg/modules/pr103499_b.C: New test. > > > > Signed-off-by: Nathaniel Shead > > --- > > gcc/cp/module.cc | 6 ++++++ > > gcc/testsuite/g++.dg/modules/pr103499_a.C | 12 ++++++++++++ > > gcc/testsuite/g++.dg/modules/pr103499_b.C | 8 ++++++++ > > 3 files changed, 26 insertions(+) > > create mode 100644 gcc/testsuite/g++.dg/modules/pr103499_a.C > > create mode 100644 gcc/testsuite/g++.dg/modules/pr103499_b.C > > > > diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc > > index c1c8c226bc1..416a7c414cc 100644 > > --- a/gcc/cp/module.cc > > +++ b/gcc/cp/module.cc > > @@ -8648,6 +8648,8 @@ trees_out::decl_node (tree decl, walk_kind ref) > > tree_node (target); > > tree_node (DECL_NAME (decl)); > > + if (TREE_CODE (decl) == FUNCTION_DECL && DECL_VIRTUAL_P (decl)) > > + tree_node (DECL_VINDEX (decl)); > > int tag = insert (decl); > > if (streaming_p ()) > > dump (dumper::TREE) > > @@ -9869,6 +9871,10 @@ trees_in::tree_node (bool is_use) > > } > > } > > + /* A clone might have a different vtable entry. */ > > + if (res && TREE_CODE (res) == FUNCTION_DECL && DECL_VIRTUAL_P (res)) > > + DECL_VINDEX (res) = tree_node (); > > + > > if (!res) > > set_overrun (); > > int tag = insert (res); > > diff --git a/gcc/testsuite/g++.dg/modules/pr103499_a.C b/gcc/testsuite/g++.dg/modules/pr103499_a.C > > new file mode 100644 > > index 00000000000..0497c2c5504 > > --- /dev/null > > +++ b/gcc/testsuite/g++.dg/modules/pr103499_a.C > > @@ -0,0 +1,12 @@ > > +// PR c++/103499 > > +// { dg-module-do compile } > > +// { dg-additional-options "-fmodules-ts" } > > +// { dg-module-cmi pr103499 } > > + > > +export module pr103499; > > + > > +export struct base { > > + virtual ~base() = default; > > +}; > > + > > +export struct derived : base {}; > > diff --git a/gcc/testsuite/g++.dg/modules/pr103499_b.C b/gcc/testsuite/g++.dg/modules/pr103499_b.C > > new file mode 100644 > > index 00000000000..b7468562ba9 > > --- /dev/null > > +++ b/gcc/testsuite/g++.dg/modules/pr103499_b.C > > @@ -0,0 +1,8 @@ > > +// PR c++/103499 > > +// { dg-additional-options "-fmodules-ts" } > > + > > +import pr103499; > > + > > +void test(derived* p) { > > + delete p; > > +} > > -- > Nathan Sidwell >