From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by sourceware.org (Postfix) with ESMTPS id 30A263858D1E for ; Thu, 9 Nov 2023 22:57:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 30A263858D1E Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 30A263858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::729 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699570663; cv=none; b=rHmOR2YnkT4/NkAvn0wLzuoPJEQIvmFtLm3Or1/q9oFlxT743DBzMUZWXlb9LqO29UIFHEUTD4RJysr5Il17H5ZoPg+XfC19nj4SMkPpbt0YjaORC1dWXPHfgCU327oGhe17s45n+zecrdp0ij4HHTixUwGKOvLjDUjx6u4xSYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699570663; c=relaxed/simple; bh=9pvFQ//uINKxq+Kvn7yGMOwdilLUxViAfVMOLnHfgaY=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=XMMC6r0YllMlUz6F3ZGyvyh/IxvtZqGnUEVZrRjdDiGzc5moaKW7Lvu1zPpZVqtbphj8vtnqzEeYfcTEAhaiMsZ5xnZn/gQrpytwgC5t1bIBjMcQjnXqt+PHKzTfoEHwllKLSN+V01bqzMVz9HMa7mU130rTNMscR3I+PsB0I+Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-778927f2dd3so86238385a.2 for ; Thu, 09 Nov 2023 14:57:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699570660; x=1700175460; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=6L1gOprSazQo9ZC24vJM6yw8xF8KM3TCJtmrH0PgHqs=; b=KkTl4gxMbxGkJ/QH8eCgbDH6U4iO/MWo4qvyZ+JbwD5/XIiUX36mIXsYDkicLnR/CQ WXJ+lQA8tk7yBq4ypEs7IoEIX2gR5X82gzMFAkh6OUv0O2nMvvZJfqvRLn7feCDsBqVc LTETt7LRmytShEwaQKnf4NpG/Qp7NqVLnbpE365VfrNJVOwWTaJP3mDCHlevyYT7TS03 bLHfpHoQ5ow8nzvhQ0w5imCouCMfve82iWBYpVd7dLxEM2KnR/3PkcYRTNUw9d5MZqu6 ngvAusxRCKeTLdGRZ7clyfilHhBBQl9iKfzDKFbwH0T/nLpaLTfylZFO0QyX2/sgJtVj yA6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699570660; x=1700175460; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6L1gOprSazQo9ZC24vJM6yw8xF8KM3TCJtmrH0PgHqs=; b=M4TrTLV96Aj/sqH2Q/W3lwmtAGH16G0ijZio2YaoDc8+j4tsKyQelwpTNZ0AT2vkZS bd/W89XrUZKPzLa4gDC8h1S24pkUwzTdFMXcenShBzhprcp4WmYjh0WqshGL1IKMKbcN 94//v+RDw0D0Y7PDWsOMW9pTCZY6BS8+Ru5iTzNl3btjM99zDuuVa/pLwG7uxBnuDsab 7o9V6bsbHQ4JOWC2ijYssSRo94jEHksmC+lcSb/RPPzaSVxhIiE4aqvbjofVa9eJi2oV VMFUK48Ec4+VrTMHmsf85gidTAPCBrMcZy3LYL1wbKrLodHREWMRf0f0Hg/B6iCIxr4p WLcQ== X-Gm-Message-State: AOJu0YwohwC0uZgYuMB3kHAU9XyLOeIM5Qa8hRNdoRKwwzjfxSAr6AM7 W49klsTsrc8m/+qL+k0O1T0= X-Google-Smtp-Source: AGHT+IFFUpDfXef3T+RI9jjm8xvDTJFzhtN8faKw9CueXGm6SWh8fuxAy+R5WpkHZyjXMZLvnsSAug== X-Received: by 2002:a05:620a:4248:b0:774:3963:41a5 with SMTP id w8-20020a05620a424800b00774396341a5mr5935303qko.13.1699570660455; Thu, 09 Nov 2023 14:57:40 -0800 (PST) Received: from ?IPV6:2601:19c:5282:9160::4? ([2601:19c:5282:9160::4]) by smtp.googlemail.com with ESMTPSA id g20-20020a05620a40d400b00767dcf6f4adsm263382qko.51.2023.11.09.14.57.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Nov 2023 14:57:40 -0800 (PST) Sender: Nathan Sidwell Message-ID: <19c6ccd9-f3c3-416a-9124-b827bf002a07@acm.org> Date: Thu, 9 Nov 2023 17:57:39 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++/modules: fix virtual destructors [PR103499] To: Nathaniel Shead , gcc-patches@gcc.gnu.org Cc: Jason Merrill References: <654cacb3.170a0220.9f692.95e6@mx.google.com> Content-Language: en-US From: Nathan Sidwell In-Reply-To: <654cacb3.170a0220.9f692.95e6@mx.google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3038.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: 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 > > 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