From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe35.google.com (mail-vs1-xe35.google.com [IPv6:2607:f8b0:4864:20::e35]) by sourceware.org (Postfix) with ESMTPS id D1A3A3858D33 for ; Thu, 23 Nov 2023 16:45:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D1A3A3858D33 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 D1A3A3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::e35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700757935; cv=none; b=coKajsqNjZ1b52hMDWVB3TxdluQcBNAxEOXyvrJfmXmMQCXbBNuz/H/ykW7rWVoLSVmOKkfGaO2b/MJUJq+X74xW/nU2xfjq+2eK8t5oyl/K3mCrJh/eTP+2CGvunIji+l3YnrICIfEzr5EKDqtOY9IP+X78ANt+QMVL5YTdfj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700757935; c=relaxed/simple; bh=voblFZNaT9hXh5TMw73KhsPJPfGkiaUHhw72VtQCalU=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=fooQfmhMS0Kzhid0Pc39s6Nvr05Y0ZJMTq7j/KHkW1/jb8/1ekqwxI/xbxn5BCoWuGcLtU2aB1Ykn7PTRFsOPJzZbrD2jdBfz6aEq8HnruNuLv/H2d7br4BUFrips9tXt2L8N0jsv/X2zE/K6ihr33KFLVgMn0p79xTwx7tNk+s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-vs1-xe35.google.com with SMTP id ada2fe7eead31-4629afba9acso326648137.2 for ; Thu, 23 Nov 2023 08:45:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700757933; x=1701362733; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=3/12Q3HXsj7h+tY/DG1tRLB4wI1Nn8lgIVnnqncdSXE=; b=ap+d8YX9z2yBDZzaq/TSbLlzSiUTHgr95AJMv2fFEOw4eppdvO6dEBKIoCS9QJMR74 pBfD0p+NHihj+XQE2ETp+znyM9/bUcg6TvuNQu6kQ89UFLhPR+Tze2PdbY7FybOJXqR5 UoMBymJ4E6xBijovO2SFv2OnfaVrLNzKm5tAlSOfaa1J6gj+VnoHz5+u4KIIG9nYFEgf 8yJcjs//VcdG1HCR/NHTMH0YLInbIS5vRT4My/rsVW6M9HTDX8uDK8sGh1pUfogzeYCC IN5JNWQLOtbHqADz+YEIZe6rOHB0I3gES0Tv3MdXDioPngUHiR+u1yyV8eeGlfv5dgNI 6alg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700757933; x=1701362733; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3/12Q3HXsj7h+tY/DG1tRLB4wI1Nn8lgIVnnqncdSXE=; b=sPCGwKyhd4lbmTe5TAq5olXuAlzaikM7dTtTKQQxNvfsll6ni1lOpUlEXh4kFuR1aP dGPeeTDwESl6VEYL7fNS7OuGOYcCVMeIEKJioB55mKN3/EKnl55GQh/YCA/9XFUChl1o iyxZzajine8THLB7n2f2ujjzXZ2bXjj0nk7FXLu9qWfudVfyZAvp6wLxkwdA7V6DEMjf x5SwSfZZmgN/Lb5Ck2PjKHOkVSjnL6I+tSQEu2BSP+81dDhHpexprol+Q7IITZvmbx3A hYWlBHt+0Fjnc6n0qRUgF3GXEjBlIEB1332fwpcshOw5intp7+qkr6JPhISV7r07zfql ipPA== X-Gm-Message-State: AOJu0Yx+xp0n705EVRkvluvhW+6t96JhrOtacTQ+g8hKH8wtTLY+4pqa 7xnTqfCSQrl2uQihR/SptmM= X-Google-Smtp-Source: AGHT+IHc0hVjSHgGEWzh6MJ6t1itcikHpwZ+Az3jD9ZcngiC8oPOoGZb9nmyt7Ks7kpDLmBvwyoSSw== X-Received: by 2002:a05:6102:54a7:b0:460:f40a:95f8 with SMTP id bk39-20020a05610254a700b00460f40a95f8mr194443vsb.24.1700757933135; Thu, 23 Nov 2023 08:45:33 -0800 (PST) Received: from ?IPV6:2601:19c:5282:9160::4? ([2601:19c:5282:9160::4]) by smtp.googlemail.com with ESMTPSA id w11-20020a0ce10b000000b0065b12c7a48dsm629748qvk.133.2023.11.23.08.45.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Nov 2023 08:45:32 -0800 (PST) Sender: Nathan Sidwell Message-ID: <8b8cc02d-b527-48d2-b5cc-896251224551@acm.org> Date: Thu, 23 Nov 2023 11:45:31 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/1] c++/modules: Allow exporting a typedef redeclaration Content-Language: en-US To: Nathaniel Shead , gcc-patches@gcc.gnu.org Cc: Jason Merrill References: <6550be76.170a0220.b3f34.4f25@mx.google.com> <6551bdb9.170a0220.9dd60.6ce4@mx.google.com> From: Nathan Sidwell In-Reply-To: <6551bdb9.170a0220.9dd60.6ce4@mx.google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3038.1 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/13/23 01:09, Nathaniel Shead wrote: > I happened to be browsing the standard a bit later and noticed that we > incorrectly reject the example given below. > > Bootstrapped on x86_64-pc-linux-gnu; regtesting ongoing but modules.exp > completed with no errors. > > -- >8 -- > > A typedef doesn't create a new entity, and thus should be allowed to be > exported even if it has been previously declared un-exported. See the > example in [module.interface] p6: ok. Could you put a reference to [module.interface]/p6 in the comment though? nathan > > export module M; > struct S { int n; }; > typedef S S; > export typedef S S; // OK, does not redeclare an entity > > PR c++/102341 > > gcc/cp/ChangeLog: > > * decl.cc (duplicate_decls): Allow exporting a redeclaration of > a typedef. > > gcc/testsuite/ChangeLog: > > * g++.dg/modules/export-1.C: Adjust test. > > Signed-off-by: Nathaniel Shead > --- > gcc/cp/decl.cc | 5 ++++- > gcc/testsuite/g++.dg/modules/export-1.C | 6 +++++- > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc > index bde9bd79d58..5e175d3e835 100644 > --- a/gcc/cp/decl.cc > +++ b/gcc/cp/decl.cc > @@ -2231,7 +2231,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) > } > > tree not_tmpl = STRIP_TEMPLATE (olddecl); > - if (DECL_LANG_SPECIFIC (not_tmpl) && DECL_MODULE_ATTACH_P (not_tmpl)) > + if (DECL_LANG_SPECIFIC (not_tmpl) > + && DECL_MODULE_ATTACH_P (not_tmpl) > + /* Typedefs are not entities and so can be exported later. */ > + && TREE_CODE (olddecl) != TYPE_DECL) > { > if (DECL_MODULE_EXPORT_P (STRIP_TEMPLATE (newdecl)) > && !DECL_MODULE_EXPORT_P (not_tmpl)) > diff --git a/gcc/testsuite/g++.dg/modules/export-1.C b/gcc/testsuite/g++.dg/modules/export-1.C > index 3f93814d270..598814370ec 100644 > --- a/gcc/testsuite/g++.dg/modules/export-1.C > +++ b/gcc/testsuite/g++.dg/modules/export-1.C > @@ -9,8 +9,12 @@ export int x (); // { dg-error "conflicting exporting for declaration" } > int y; > export extern int y; // { dg-error "conflicting exporting for declaration" } > > +// A typedef is not an entity so the following is OK; see [module.interface] example 4 > typedef int z; > -export typedef int z; // { dg-error "conflicting exporting for declaration" } > +export typedef int z; // { dg-bogus "conflicting exporting for declaration" } > + > +template using w = T; > +export template using w = T; // { dg-error "conflicting exporting for declaration" } > > template int f (T); > export template int f (T); // { dg-error "conflicting exporting for declaration" } -- Nathan Sidwell