From patchwork Thu Oct 20 14:07:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1692533 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=lGMU8S7y; dkim-atps=neutral Received: from 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MtTw52clKz23jk for ; Fri, 21 Oct 2022 01:08:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 59A953850850 for ; Thu, 20 Oct 2022 14:08:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59A953850850 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666274899; bh=8Faw1g3d6ugWSPrGXzPA3EcSDdMq2XaNc/ELV5+8uOs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=lGMU8S7yhVt1Mp3mTur42z6DGjreTGzAme3rfx6amW1Z4EU0XrowaTQc2IpWTKkr0 xpS0H7cnHtnoXc/pTXwVKnBEP7UBzHV/0cb9aqoIqCcSuKRDv6DfEV2I7r5sL8slNG gSF9sQHPI0ijNfdmLvl0Fqeu67OezcGw2Mjjdq9A= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 5798F3850202 for ; Thu, 20 Oct 2022 14:07:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5798F3850202 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-633-fkQkjMB8MpugMCze8BBEUw-1; Thu, 20 Oct 2022 10:07:55 -0400 X-MC-Unique: fkQkjMB8MpugMCze8BBEUw-1 Received: by mail-qk1-f198.google.com with SMTP id bi38-20020a05620a31a600b006eeb2862816so17348307qkb.0 for ; Thu, 20 Oct 2022 07:07:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8Faw1g3d6ugWSPrGXzPA3EcSDdMq2XaNc/ELV5+8uOs=; b=KJryDeoSMpi3A97dK54iE7mQe02QTIS2pM2eDJgWL3hxlgULcbSqRae8qh2N0PqIwc oeJFsJXJhZLd+3jyeiS8hESdE+NlEj5r91r6zwlHQQHoL/Gy1t/G10mDX1iSuZOZeoB3 3B3EimisD3+mfHfaAOuKSBkJYvpM/nbxQolqcJxp4kANCgqOUUNP4oEz3BC4dy1GFiFu NiF6F6b5U/nPI9+reHn5CFScbWNja1rjKjdyuL/Dlyn8zOKuQcXNwtzdTdJSJMwFnNhE 71gG//kxCeaDO5OE+Nyiukjlq445jbWFx6J+Dmuzdst/kEh6UsAncV4vylBs2hg+bNqv rShw== X-Gm-Message-State: ACrzQf0PdbtvCIqDEDwS97+kKwaRgMlNQUc3StcbmoBKPp+lFTtDeCKg YQ2yZq+h6nyswjPp6RGKO0tQSvWmVpDJ4bhFUWm5jbFn5KkyV+wkwiGUnS6U4xHtjwohawkKyWf 7WbJlw7sCNUVTmQJfZyU8Eov1CyxzJeDG0G2EEIKNJqgSr+F4NTgPUPrmv5A3rNiHles= X-Received: by 2002:a05:620a:2618:b0:6ea:908:120e with SMTP id z24-20020a05620a261800b006ea0908120emr9243275qko.645.1666274874633; Thu, 20 Oct 2022 07:07:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5rc8angiinGiCcCrzl0H/0g9wuQ0KMMd/PbOHNQcSF01257OlwWsEmYvudjohwJP2qVjmilQ== X-Received: by 2002:a05:620a:1927:b0:6ee:94f6:b9fb with SMTP id bj39-20020a05620a192700b006ee94f6b9fbmr9279883qkb.80.1666274863255; Thu, 20 Oct 2022 07:07:43 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id he7-20020a05622a600700b003972790deb9sm6077692qtb.84.2022.10.20.07.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 07:07:42 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++ modules: handle CONCEPT_DECL in node_template_info [PR102963] Date: Thu, 20 Oct 2022 10:07:40 -0400 Message-Id: <20221020140740.415427-1-ppalka@redhat.com> X-Mailer: git-send-email 2.38.1.130.g45c9f05c44 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Cc: nathan@acm.org Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Here node_template_info is overlooking that CONCEPT_DECL has TEMPLATE_INFO too, which makes get_originating_module_decl for the CONCEPT_DECL fail to return the corresponding TEMPLATE_DECL, which leads to an ICE from import_entity_index while pretty printing the CONCEPT_DECL's module suffix as part of the failed static assert diagnostic. Tested on x86_64-pc-linux-gnu, does this look OK for trunk? PR c++/102963 gcc/cp/ChangeLog: * module.cc (node_template_info): Handle CONCEPT_DECL. gcc/testsuite/ChangeLog: * g++.dg/modules/concept-7_a.C: New test. * g++.dg/modules/concept-7_b.C: New test. --- gcc/cp/module.cc | 3 ++- gcc/testsuite/g++.dg/modules/concept-7_a.C | 7 +++++++ gcc/testsuite/g++.dg/modules/concept-7_b.C | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/modules/concept-7_a.C create mode 100644 gcc/testsuite/g++.dg/modules/concept-7_b.C diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index bb406a5cf01..dfed0a5ef89 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -4046,7 +4046,8 @@ node_template_info (tree decl, int &use) || TREE_CODE (decl) == TYPE_DECL || TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == FIELD_DECL - || TREE_CODE (decl) == TEMPLATE_DECL)) + || TREE_CODE (decl) == TEMPLATE_DECL + || TREE_CODE (decl) == CONCEPT_DECL)) { use_tpl = DECL_USE_TEMPLATE (decl); ti = DECL_TEMPLATE_INFO (decl); diff --git a/gcc/testsuite/g++.dg/modules/concept-7_a.C b/gcc/testsuite/g++.dg/modules/concept-7_a.C new file mode 100644 index 00000000000..a39b31bf7f0 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/concept-7_a.C @@ -0,0 +1,7 @@ +// PR c++/102963 +// { dg-additional-options "-fmodules-ts -fconcepts" } +// { dg-module-cmi pr102963 } + +export module pr102963; + +export template concept C = __is_same(T, int); diff --git a/gcc/testsuite/g++.dg/modules/concept-7_b.C b/gcc/testsuite/g++.dg/modules/concept-7_b.C new file mode 100644 index 00000000000..1f81208ebd5 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/concept-7_b.C @@ -0,0 +1,7 @@ +// PR c++/102963 +// { dg-additional-options "-fmodules-ts -fconcepts" } + +import pr102963; + +static_assert(C); +static_assert(C); // { dg-error "static assert" }