public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@acm.org>
To: Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org
Cc: jason@redhat.com
Subject: Re: [PATCH] c++ modules: ICE with bitfield member in class template
Date: Fri, 7 Oct 2022 11:23:31 -0400	[thread overview]
Message-ID: <e6d21fb8-affa-7b7c-f8c1-fbaa8cc72d73@acm.org> (raw)
In-Reply-To: <20221007150952.102429-1-ppalka@redhat.com>

On 10/7/22 11:09, Patrick Palka wrote:
> 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?

ok, but could you add a comment on why it might not be a decl?


> 
> 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<int N>
> +struct A {
> +  int x : 1;
> +  int y : N;
> +};

-- 
Nathan Sidwell


  reply	other threads:[~2022-10-07 15:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-07 15:09 Patrick Palka
2022-10-07 15:23 ` Nathan Sidwell [this message]
2022-10-07 15:54   ` Patrick Palka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e6d21fb8-affa-7b7c-f8c1-fbaa8cc72d73@acm.org \
    --to=nathan@acm.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=ppalka@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).