From patchwork Mon Nov 13 06:09:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathaniel Shead X-Patchwork-Id: 1863022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=giQ8HzTj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4STJvJ09NDz1yRX for ; Mon, 13 Nov 2023 17:10:35 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A1A03875424 for ; Mon, 13 Nov 2023 06:10:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id BE9EE3858C29 for ; Mon, 13 Nov 2023 06:10:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE9EE3858C29 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 BE9EE3858C29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::430 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699855806; cv=none; b=r/Q/q+klzR8YSVTfYDy8prR4cIppe8voSgAIQ/NBjQ4Ov2tXOmO0COCquP/L2xY7lThZbqvYEG6MKnSIziI00qVecxgnB/bqSGTOc/oMjsPVKZ7WwpX54FYVID0cqcu6G8ymj/NezYGEY0LN/k9e22395wk11jpWs6PgvOroSKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699855806; c=relaxed/simple; bh=E3Nh91I4A8FuYcFm5Nq4Y+fFNgHb3DycnkgC22sDGU0=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=DDelI3LAagd2J5yYPcrJUhuxB1RbHQ5TzeKRTN+LFqngENsb51fDB0Iuvs8loXineRf+JF9XWz8KansNFpBiUexdPibQPPwD0EDyW4mrsltvhD3M6ILJw7I/pepIBh/Jc0NOQZDhaPyooUeYJ9lE5v4Eux5HRdJoODz67gpUl5o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6b7f0170d7bso4076754b3a.2 for ; Sun, 12 Nov 2023 22:10:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699855802; x=1700460602; 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=8A6X2/FH9qlptH1SeBljTrWoUf+YUPpapvzVRCZl+sE=; b=giQ8HzTjZdSq2N4ktp50J+Jqa2aszANkVbHJTcr1HKLclPlpzbLK3N94P5qwvm1Hxg Wtu5xwyWtpywzWBCqq7185JurzN9adzashGazi/BulG+5AR/I108SGZuaORgb7QkMpbb tLV6D7/lykwm/oSRIVEf+GGAJkMJdp5vWA9IN4yjDIHRACx3126b2eVNQIJbitI9acOj psQhfGMrxjm6CUqkDN+Xue8tLFDtx1SLdKmt93tk0b9r4tZ9VCUy5spMB6Uif8JTkbSU haINVG+49/0qmWWjzH5DaSvucryRh8169BlZFbab99otB6MEE4tVjgQAJkEtVhB/Czdt GD1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699855802; x=1700460602; 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=8A6X2/FH9qlptH1SeBljTrWoUf+YUPpapvzVRCZl+sE=; b=wSCl4yn6GEHLlzYAaVXeCyOgLfeSMMCJGA6ITQnsi8hmOFuC0kVdUbh2yZDcaXv6HH Tc5F2NyrL1a8UIDHU5eE2mRlur50ULLUI51ZOdImY3ts1/LDL4muUVQVV1avQ87jwfNl gGz1EBwqCoi5Sv2d/NWUxunxpC2aIez2WNzBedwa5c+KOA+8kaa1eaI6GhhHxVvorazf 9gahhhdLWa+4wlLaS/TCZrllfohagcRejsDyZbZfibTqHrhugEFC3/nppoFh5qM/36FL 5liLVQ+mo6aEROd/Ej3512Dyc0/AC37Ui1/Ojgs9YY+1kT9GBkokyNgISWRJ5BBboPZe uFlg== X-Gm-Message-State: AOJu0Yzbx1SJx/dTz9Iga8fVj9j4gLZr6CiraDmG7/lymXGUgi4K6Rrc 7i9UdY1CCOyjavPfCkBrmQ80x395Bh0= X-Google-Smtp-Source: AGHT+IGLPCdTOxP942Xt98ZDi5ZdteQhUYYrAnojeS/otqqT9TidlxZZHaE5J4yX+90a4YcMd/9Xyg== X-Received: by 2002:a05:6a20:244e:b0:15e:d84:1c5e with SMTP id t14-20020a056a20244e00b0015e0d841c5emr8046294pzc.38.1699855802136; Sun, 12 Nov 2023 22:10:02 -0800 (PST) Received: from Thaum. (124-150-88-161.tpgi.com.au. [124.150.88.161]) by smtp.gmail.com with ESMTPSA id j24-20020a170902759800b001bdd7579b5dsm3346832pll.240.2023.11.12.22.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 22:10:01 -0800 (PST) Message-ID: <6551bdb9.170a0220.9dd60.6ce4@mx.google.com> X-Google-Original-Message-ID: Date: Mon, 13 Nov 2023 17:09:57 +1100 From: Nathaniel Shead To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell Subject: [PATCH 2/1] c++/modules: Allow exporting a typedef redeclaration References: <6550be76.170a0220.b3f34.4f25@mx.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <6550be76.170a0220.b3f34.4f25@mx.google.com> X-Spam-Status: No, score=-11.9 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 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org 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: 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" }