From patchwork Fri Oct 7 15:09:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1818 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp347771wrs; Fri, 7 Oct 2022 08:10:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4wP9KvC4ky1G1iOW3FrfrHifgcZfO8Id3clB7WoCoG2X5NVk0OukYtiHInluL16ZV9CEgb X-Received: by 2002:a17:907:2d2c:b0:78d:427e:398b with SMTP id gs44-20020a1709072d2c00b0078d427e398bmr4472914ejc.640.1665155442617; Fri, 07 Oct 2022 08:10:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665155442; cv=none; d=google.com; s=arc-20160816; b=wUnkz5qUhxwWgzuc+sn5mWIKH0JLNsbV5cVmN+viWqMOgxgqlf4KMNUfPtF4jKDnm+ X7H94x/byeOcmFaR0LhlCG2gLBpSrm6dMR/wemHoxcw0dtjJPgAyEZqb8RD0JiGhNOvl yD7wuI5Q7gNPfSfWcegDh2FA6z6SWmltp29G8Lcbhj0Oj1K/6/Bu40h8KIZjIjwmyBX9 9k89KRjeVu73/lMHghPdw12aERr2C4ErC8s53US7l1E2bpJ/xe6cY3gpgWHiceV244CB 0e6zMKU+18OqIXdGYM+34fO0c1HX5PrgPcsh7Nej3tANwRjFmhlcITpJvXBtP55vgkhh nvOA== 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=J3vkffE+vcc8M2jaYtzZ7qalyxyYixwiAhCxLbUvfH8=; b=I8OlOcVtkQj4nG94f+WydaQFIUL9k6cDYDqlCDQElZLfQqRx/fhUfGXPDRObCefzFR Xjsz5THtWD6y2LJCRkK29bTja6DfV6xAmmovdPqrtYC8rQG15Dig3snITpoUF23FWN2w fEakQdPDCyxFKsDbZ95ORrlKz18HQ6w6hz56t1MyvlAKRZ/z20ekFJ1INwxUrRuXht2Z lzmxoeDNudGkDCh7IJWZoro0EIfBrzW22pvE1iaLYsRpKEB7vszTlthj10Ux5LGWv9ZX UxboIcLriBtXjYk6jr522ajl8JqieaUMepzELJfh+Yu3CVNEl10acZrkjxCSSroWvt/s unSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FV4GlZEU; 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 ht21-20020a170907609500b0078cffe59b3asi819482ejc.56.2022.10.07.08.10.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 08:10:42 -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=FV4GlZEU; 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 49B58382F99D for ; Fri, 7 Oct 2022 15:10:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49B58382F99D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665155441; bh=J3vkffE+vcc8M2jaYtzZ7qalyxyYixwiAhCxLbUvfH8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=FV4GlZEUMt637rCTZUppSGtaI7WEQcHtI9MpIpjaHzapb8EtZgn9XtGEgUMSs8Gpc KK1xOhgCEA+NUHnMc7fpHTMBaw5vDKA0KYqYVAzHV4lwsuyM7pwA/1emj2NjTKtcDp osJdeKqFMR67wHTQwhj9EQonTcGdX+yXf73CWIls= 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 3C96E3858CDB for ; Fri, 7 Oct 2022 15:09:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3C96E3858CDB Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-531-AzLogzq7PZan5_f_gkbmMg-1; Fri, 07 Oct 2022 11:09:56 -0400 X-MC-Unique: AzLogzq7PZan5_f_gkbmMg-1 Received: by mail-qk1-f200.google.com with SMTP id j13-20020a05620a288d00b006be7b2a758fso3937888qkp.1 for ; Fri, 07 Oct 2022 08:09:56 -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=J3vkffE+vcc8M2jaYtzZ7qalyxyYixwiAhCxLbUvfH8=; b=1ngJXhGo0+hYO9qPwLaWMLUCPxkZfu4deGyNfkikZqBp/LZqqUCnVUqIuDNPNYN4Tz /jbioiJGigQv7XpvVPqFu2vDm4fb6pnfrg5fpFbsNgb5Y5OaMIqLYEKtBX47o+m64y/7 xQhbTsGR/F4V1GdhfyFK/CG3CThSzTa7BFJ/i4KbATlh2Yc5rj14UMEWCLsCb0uTo+p8 YfHg1MBy/sDRRwoPbMXFU/nP/9hVFGkXQ2N8yQaG3wqP2L/JsWTpCWsRgrVhh2tWy6IF q5wcZoz7LJiufhSluIruJvOTQBBgdphUEcIj0tlrRFgnsyzqxH47eegHwm6I6S1Ni2S9 e+KA== X-Gm-Message-State: ACrzQf0MUM2hMehKm0QdEklEzL76gNV1LGMf7z/43kCH2qVjEOOzrjbB 1awGQ8pGYJPgn68evClusaqdqcwyTvGrBxJJxB2mT+8l1M7uyLjVsCC6/YXI+AkcEFeB9ryiO3r Pf1FRH69KPZ7BC6O6ZyyV3QQSnKFvBUgIlSS/WhQ2nGrE3rotOHwdxZFOD3lX/K6pzWw= X-Received: by 2002:ae9:f715:0:b0:6e7:73bf:63c9 with SMTP id s21-20020ae9f715000000b006e773bf63c9mr3880448qkg.225.1665155395448; Fri, 07 Oct 2022 08:09:55 -0700 (PDT) X-Received: by 2002:ae9:f715:0:b0:6e7:73bf:63c9 with SMTP id s21-20020ae9f715000000b006e773bf63c9mr3880430qkg.225.1665155395141; Fri, 07 Oct 2022 08:09:55 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id f11-20020a05620a280b00b006ce515196a7sm2295911qkp.8.2022.10.07.08.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 08:09:54 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++ modules: ICE with bitfield member in class template Date: Fri, 7 Oct 2022 11:09:52 -0400 Message-Id: <20221007150952.102429-1-ppalka@redhat.com> X-Mailer: git-send-email 2.38.0.rc2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.3 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_LOW, 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?1746042033166339141?= X-GMAIL-MSGID: =?utf-8?q?1746042033166339141?= According to grokbitfield, DECL_BITFIELD_REPRESENTATIVE may "temporarily" contain the width of the bitfield until we layout the class type (after which it'll contain a FIELD_DECL). But for a class template, it'll always be the width since we don't/can't layout dependent types. Tested on x86_64-pc-linux-gnu, does this look OK for trunk? gcc/cp/ChangeLog: * module.cc (trees_out::mark_class_def): Guard against DECL_BITFIELD_REPRESENTATIVE not being a decl. gcc/testsuite/ChangeLog: * g++.dg/modules/bfield-3.H: New test. --- gcc/cp/module.cc | 3 ++- gcc/testsuite/g++.dg/modules/bfield-3.H | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/modules/bfield-3.H diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index cb1929bc5d5..172a72e92b9 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -11919,7 +11919,8 @@ trees_out::mark_class_def (tree defn) mark_class_member (member); if (TREE_CODE (member) == FIELD_DECL) if (tree repr = DECL_BIT_FIELD_REPRESENTATIVE (member)) - mark_declaration (repr, false); + if (DECL_P (repr)) + mark_declaration (repr, false); } /* Mark the binfo hierarchy. */ diff --git a/gcc/testsuite/g++.dg/modules/bfield-3.H b/gcc/testsuite/g++.dg/modules/bfield-3.H new file mode 100644 index 00000000000..4fd4db7116a --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/bfield-3.H @@ -0,0 +1,8 @@ +// { dg-additional-options -fmodule-header } +// { dg-module-cmi {} } + +template +struct A { + int x : 1; + int y : N; +};