From patchwork Fri Jan 19 22:36:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathaniel Shead X-Patchwork-Id: 189684 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp1318369dyb; Fri, 19 Jan 2024 14:38:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfgjrFvy1gCMmZK1ZxajP2YEM28OqTw2iNl56ENt3rEwsYBbiZ82/V20QbgiYWrgupKtvb X-Received: by 2002:a05:6808:124d:b0:3bd:6833:3c78 with SMTP id o13-20020a056808124d00b003bd68333c78mr456083oiv.35.1705703925971; Fri, 19 Jan 2024 14:38:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705703925; cv=pass; d=google.com; s=arc-20160816; b=K5YaNSWqoiG2lW1TfhXHDZ7dzxUwzo5GKzUebm/XQR+dFc2c1qXYioqdt9I9jsXn9l sCXEdGmyXrskZujXJsCAE7aaImuPnxawPyKzQjQCb0Vk8hrRjIspdVK43A2o19SzstQ8 p/vhD1djwIoLGlbGlJuaMpI0FBWuW58Al9RZogos4OuAu2xxKips3PAV4NLCVqP9nwZb 13Pv1eHZsPCy93X8JTEJjh+NfGS6gm7p3amGc8NxqzW9pjGknAxDhwGcCEpSYVqN0Xte jqpdnh2OSY/oAP9Y4m5b+aXAgvchB92xsIl9CUXuUBrEB70Bk5mxcY40Zo0VmU2h0IY8 Wrcg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:subject:cc:to:from:date:message-id:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=jyIgV6koummUl+O0Q01yHgFruxALIWgB+XpLcG9SOZc=; fh=PSfnKtImOwcFiHTY31kD+1EEfyCGdToyJVXnD0Outng=; b=B6bmbXCOvbXbR9zxzFK3+bUlaMJtgu1Mb5JIFiWau2i+zSi2bYGLQf3BByrh4Cq9Xl harWOrhq2llf1H+gFM5iyIYQH91Usk7bN3YAfJvZryprGiCAXP6+VU8tx22z3ghtUgHJ ms0VwDjaF3DHOq4XPItOX9gegE9vXk6WetCkcOeIFCO3F1rAY83lZ6BfDIRFnRjhqPgb r3sS6ALajHWuOZBqNp934BBsRfu6afc1bFagKgz9vODQxayJznfqp815wRFXH9a3Oa31 xpPliiJ7laf3MrF0ZRQeraki5MD+sXrCXDYw/7+H8k3Gq7ogStEIfEhfXuZqPyC77Xrk CH0w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Piz9j0l8; arc=pass (i=1); 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c9-20020a05622a024900b0042a0c9e3672si240573qtx.312.2024.01.19.14.38.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 14:38:45 -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=@gmail.com header.s=20230601 header.b=Piz9j0l8; arc=pass (i=1); 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9517D3858288 for ; Fri, 19 Jan 2024 22:38:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id 63CF73858D3C for ; Fri, 19 Jan 2024 22:37:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 63CF73858D3C 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 63CF73858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705703823; cv=none; b=p7bIKTJU9v5D18tyA723FcKmdYu0e2tR9QfWi3uHHflGwvdXOYTRcdEW6RgOJr/UAA71wS2kU3YtTepAnCVSBuyVfkZaMzidmE5Q/JjUI4vzqr1paeMkBDRyvs5X9kMU/kByBg53JaOoWqrOaSU+fBwDlNCzqzLYnzZgfva3A1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705703823; c=relaxed/simple; bh=j4jit0d1JJsx+t7muZjCd8gUKpS+dPpcqAtkRP35rQY=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=rm068BEZiinxnWLyL5luZznOyX2p0fbH+XwMHmd+YY2lJdnsNuqU/wiJV9FnR/ZHSZUl2X40PQw4vgabFDZ9/eViuDitZU+5HdJSBIdOsEJp29iSYId2NIJ2R2+KehlfNbJqeltsiGLlG0UJglQQp3vCD5qFNQ2lKSfJMrLDkxo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5c6bd3100fcso749366a12.3 for ; Fri, 19 Jan 2024 14:37:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705703819; x=1706308619; darn=gcc.gnu.org; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=jyIgV6koummUl+O0Q01yHgFruxALIWgB+XpLcG9SOZc=; b=Piz9j0l8y9WJAJ/o5PfB7agNAnxZGzM4xFRpEPXhIVuOc9NvnnBleHOzR5+GrnO4aX qNz2AWoSg6IRXbDepXfO7V34mdlKLQyzEAt3iDoL7cyXygUfYxQvoLQVf5Q52ezy40ML 4O4ZDqgAQenrLQq0nu7N//pUQr2s2M79rWYSQlSoxvHbEmrvQo6e5SV/1LI+s2+FHHI+ jthUPZ0FzUHp3FlVjWU6cnKi480bK2+7dEDFHXiJ7YCyhM3+JLYGvhPQyzHS3tQg3gxu ZsDqHzAqaMw1oOFWe0Zie/JVcgNcwaGg0i+WdaF7BJv6I02X4d1pC3G2Tcieeho9IyDT DrKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705703819; x=1706308619; h=content-disposition:mime-version:subject:cc:to:from:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jyIgV6koummUl+O0Q01yHgFruxALIWgB+XpLcG9SOZc=; b=djAEhgF06iLCJsH+CPSooB5LlPzh1sYNSdagAoKVIWjHPmxItqlAvLbMY71C3TAniX Go3akScXmeZp7h/1RXT/+ZbRBeYDBrqeh7MYPHTZY2zwiI8t4WfrTv7nYI0ua0EP0cvu lAJOMlUgrLC6Lbo2UDvEa4QJ2pXUAh8YYEMFeBHiIYnflxgBCt7yfkylW+POUbqq9ig1 nYTqsum/QcOZrV1qksypQYwom/3/rCI8tg7wNP8KHCymFD9D0/eRKSS9fAhvqLYug/lw xUP4UbUsc2Y80oy4NI2aInLsgWnSQ021iXyKkrCrFWC68htu4/8JcyPyDuf72mdEEXQ0 RgLQ== X-Gm-Message-State: AOJu0Yzt2G/qSROaPIa3xvAWmTW0aPagsqgYEMm1WpITgwa0NtUDhUH4 9UqZvhSdWUz0Mba7BycIGr23vGMH/Gj0NTTW/cQACDH1R9+SQG7PyLOYvf/Z X-Received: by 2002:a05:6a21:33a9:b0:19a:4010:b820 with SMTP id yy41-20020a056a2133a900b0019a4010b820mr702622pzb.12.1705703819365; Fri, 19 Jan 2024 14:36:59 -0800 (PST) Received: from Thaum. (123-243-206-49.tpgi.com.au. [123.243.206.49]) by smtp.gmail.com with ESMTPSA id y5-20020aa79e05000000b006d9ef76732esm5618441pfq.213.2024.01.19.14.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 14:36:58 -0800 (PST) Message-ID: <65aaf98a.a70a0220.d7023.9f0b@mx.google.com> X-Google-Original-Message-ID: Date: Sat, 20 Jan 2024 09:36:53 +1100 From: Nathaniel Shead To: gcc-patches@gcc.gnu.org Cc: Jason Merrill , Nathan Sidwell Subject: [PATCH] c++/modules: Handle partial specialisations in GMF [PR113405] MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-10.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, 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 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788560199985999680 X-GMAIL-MSGID: 1788560199985999680 Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? -- >8 -- Currently, when exporting names from the GMF, or within header modules, for a set of constrained partial specialisations we only emit the first one. This is because the 'type_specialization' list only includes a single specialization per template+argument list; constraints are not considered here. The existing code uses a separate 'partial_specializations' list to track this instead, but currently it's only used for declarations in the module purview. This patch makes use of this list for all declarations. PR c++/113405 gcc/cp/ChangeLog: * module.cc (set_defining_module): Track partial specialisations for all declarations. gcc/testsuite/ChangeLog: * g++.dg/modules/concept-9.h: New test. * g++.dg/modules/concept-9_a.C: New test. * g++.dg/modules/concept-9_b.C: New test. * g++.dg/modules/concept-10_a.H: New test. * g++.dg/modules/concept-10_b.C: New test. Signed-off-by: Nathaniel Shead --- gcc/cp/module.cc | 5 ++++- gcc/testsuite/g++.dg/modules/concept-10_a.H | 25 +++++++++++++++++++++ gcc/testsuite/g++.dg/modules/concept-10_b.C | 8 +++++++ gcc/testsuite/g++.dg/modules/concept-9.h | 18 +++++++++++++++ gcc/testsuite/g++.dg/modules/concept-9_a.C | 13 +++++++++++ gcc/testsuite/g++.dg/modules/concept-9_b.C | 8 +++++++ 6 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/modules/concept-10_a.H create mode 100644 gcc/testsuite/g++.dg/modules/concept-10_b.C create mode 100644 gcc/testsuite/g++.dg/modules/concept-9.h create mode 100644 gcc/testsuite/g++.dg/modules/concept-9_a.C create mode 100644 gcc/testsuite/g++.dg/modules/concept-9_b.C diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 8db662c0267..249d0816169 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -18860,8 +18860,11 @@ set_defining_module (tree decl) gcc_checking_assert (!DECL_LANG_SPECIFIC (decl) || !DECL_MODULE_IMPORT_P (decl)); - if (module_has_cmi_p ()) + if (module_p ()) { + /* We need to track all declarations within a module, not just those + in the module purview, because we don't necessarily know yet if + this module will require a CMI while in the global fragment. */ tree ctx = DECL_CONTEXT (decl); if (ctx && (TREE_CODE (ctx) == RECORD_TYPE || TREE_CODE (ctx) == UNION_TYPE) diff --git a/gcc/testsuite/g++.dg/modules/concept-10_a.H b/gcc/testsuite/g++.dg/modules/concept-10_a.H new file mode 100644 index 00000000000..c3a5fa727a7 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/concept-10_a.H @@ -0,0 +1,25 @@ +// Also test header modules +// PR c++/113405 +// { dg-additional-options "-fmodule-header" } +// { dg-require-effective-target c++20 } +// { dg-module-cmi {} } + +template +concept foo = false; + +template +concept bar = true; + +template +struct corge {}; + +template +struct corge {}; + +template +struct corge { + using alias = int; +}; + +template +using corge_alias = corge::alias; diff --git a/gcc/testsuite/g++.dg/modules/concept-10_b.C b/gcc/testsuite/g++.dg/modules/concept-10_b.C new file mode 100644 index 00000000000..67be13d5995 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/concept-10_b.C @@ -0,0 +1,8 @@ +// PR c++/113405 +// { dg-additional-options "-fmodules-ts" } +// { dg-require-effective-target c++20 } + +import "concept-10_a.H"; + +struct test {}; +using quux = corge_alias; diff --git a/gcc/testsuite/g++.dg/modules/concept-9.h b/gcc/testsuite/g++.dg/modules/concept-9.h new file mode 100644 index 00000000000..1c7f003228c --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/concept-9.h @@ -0,0 +1,18 @@ +// PR c++/113405 + +template +concept foo = false; + +template +concept bar = true; + +template +struct corge {}; + +template +struct corge {}; + +template +struct corge { + using alias = int; +}; diff --git a/gcc/testsuite/g++.dg/modules/concept-9_a.C b/gcc/testsuite/g++.dg/modules/concept-9_a.C new file mode 100644 index 00000000000..9a055b6dcc9 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/concept-9_a.C @@ -0,0 +1,13 @@ +// PR c++/113405 +// { dg-additional-options "-fmodules-ts" } +// { dg-require-effective-target c++20 } +// { dg-module-cmi M } + +module; + +#include "concept-9.h" + +export module M; + +export template +using corge_alias = corge::alias; diff --git a/gcc/testsuite/g++.dg/modules/concept-9_b.C b/gcc/testsuite/g++.dg/modules/concept-9_b.C new file mode 100644 index 00000000000..55a64a9a413 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/concept-9_b.C @@ -0,0 +1,8 @@ +// PR c++/113405 +// { dg-additional-options "-fmodules-ts" } +// { dg-require-effective-target c++20 } + +import M; + +struct test {}; +using quux = corge_alias;