From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1888) id 5B6493858CDB; Fri, 7 Oct 2022 16:02:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B6493858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665158543; bh=RghFq0IHA94J12wuemgAEw1qkdtRPbpcEbAWBFZfIZY=; h=From:To:Subject:Date:From; b=uOxbydzZWN1TZvJKin58kJMU9KKQT70gcCAbypwewg9pDjztFLKIsYOUMz43GMS5d +UA0dd+YjUrrUppCF6MWVsH3VfX7Ho435sEz0K6RBUWh/BSlm1SkETq05s750Q3DnS 5mfaJRJa48Docir0gS3RL7NoAQhAbiukhA3lBVEE= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Patrick Palka To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3166] c++ modules: ICE with bitfield in class template X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/heads/master X-Git-Oldrev: f8ba88b6a811ca9bb4b8411d3f65c329fb480ee1 X-Git-Newrev: f7f4628054358a92a55d52645cf107aa26ff6765 Message-Id: <20221007160223.5B6493858CDB@sourceware.org> Date: Fri, 7 Oct 2022 16:02:23 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f7f4628054358a92a55d52645cf107aa26ff6765 commit r13-3166-gf7f4628054358a92a55d52645cf107aa26ff6765 Author: Patrick Palka Date: Fri Oct 7 12:01:58 2022 -0400 c++ modules: ICE with bitfield in class template According to grokbitfield, DECL_BIT_FIELD_REPRESENTATIVE contains the width of the bitfield until we layout the class type (after which it'll contain a decl). Thus for a bitfield in a class template it'll always be the width, and this patch makes us avoid ICEing from mark_class_def in this case. gcc/cp/ChangeLog: * module.cc (trees_out::mark_class_def): Guard against DECL_BIT_FIELD_REPRESENTATIVE not being a decl. gcc/testsuite/ChangeLog: * g++.dg/modules/bfield-3.H: New test. Diff: --- gcc/cp/module.cc | 6 +++++- gcc/testsuite/g++.dg/modules/bfield-3.H | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index cb1929bc5d5..94fbee85225 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -11919,7 +11919,11 @@ 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 we're marking a class template definition, then + this'll contain the width (as set by grokbitfield) + instead of a decl. */ + 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; +};