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: 6211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp131383wrr; Thu, 20 Oct 2022 07:09:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Gob6+F1VwELq+Y1cINhaMimoUxLwkDfXT+UpFv6p3yKQKRgKMCVJC7zPGdhan4u8sJVDW X-Received: by 2002:a17:907:2c4f:b0:78d:eebe:f413 with SMTP id hf15-20020a1709072c4f00b0078deebef413mr11224834ejc.221.1666274941693; Thu, 20 Oct 2022 07:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666274941; cv=none; d=google.com; s=arc-20160816; b=Qkq02G5eC3idpvWNfYHy+6yHYfjHi5irITWW0G111kAM471R7rjaxUDnVkrVf27lZu 49MbARbB9Uxx+2hjRDvfsGyXG2mCnBjofAZW75DF5dKbvCS6wio6Qcl05oeu2rAocn7C rguEt2vkU/zJGJ5N0/LaSpp+eSSsO6cAKB/BAZscLoJIf8Gz3+MwLAtNcVzcguGJS8Yj m/j+FhgkyXWrxnnGMvzTnpKIxLHZy2ynbIBT/Yx4Dh2dzOWoMN0015/vXi871GD9gLet 4nrWEwmI0A1zzOWdOkocY/S0UInJoG7MgCQoiXJYYb2c66pquJl3+vzWUanKYa1AlU9C KQIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=8Faw1g3d6ugWSPrGXzPA3EcSDdMq2XaNc/ELV5+8uOs=; b=RKa6wHfm7R/EOwBOlD4BO6X6SJcxgPdjcLjmrPw62SgPR5U+PlB7RSLUfoodl0lqLR vIe5pt2qwMuvR0GZ/2U5PWD+NP9rRI8ZF5Z86rMc6i86LrS9+8jUPmBfvCehDHAiWqrT Q5EwCDXbb417VIehH6GNWbWG1axM/pZ8m7/Q7j54EyDVM6fv0KhBn5i8+NiL1+uK3Gwp kgDtwvU11B7dmtA6k4x9Fw8+spWUHqWfMg8iu9osHm7etQCBw6OWw+ILcFB0TKZq4O7b V6LjUc8IDA5ez2vYXwqFiI1VrlOt4Ocul66NSVOOXBD5cxJCYQL4nRNIDTVCljY+geaW hfMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MmumK4Fs; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o30-20020a509b1e000000b0045a2d9130bdsi16410242edi.457.2022.10.20.07.09.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 07:09:01 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MmumK4Fs; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 85562385085E for ; Thu, 20 Oct 2022 14:08:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 85562385085E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666274922; 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=MmumK4Fs5NRP27NzOIyv0UG8Yx/F+9MwOQjen0TNh8bp+QhSYsILSXVTxohMUqsJx ON6aa+cENfCWIsfIr/O2ESLwSg+N8qGMF6WYfUeQsnrcPtPDtSA+Op4Qb/uwDS9JhB kFOhpwpNuy7bJhp9okS8xPEyKwvnWNLlp9gr8e88= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747215913092832934?= X-GMAIL-MSGID: =?utf-8?q?1747215913092832934?= 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" }