public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r9-9437] c++: Diagnose bare parameter packs in bitfield widths [PR99745]
Date: Tue, 20 Apr 2021 23:33:55 +0000 (GMT)	[thread overview]
Message-ID: <20210420233355.82E21388A837@sourceware.org> (raw)

https://gcc.gnu.org/g:4b30a6d214ad94dfdffa93843d628484d2555b51

commit r9-9437-g4b30a6d214ad94dfdffa93843d628484d2555b51
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Mar 25 21:06:09 2021 +0100

    c++: Diagnose bare parameter packs in bitfield widths [PR99745]
    
    The following invalid tests ICE because we don't diagnose (and drop) bare
    parameter packs in bitfield widths.
    
    2021-03-25  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/99745
            * decl2.c (grokbitfield): Diagnose bitfields containing bare parameter
            packs and don't set DECL_BIT_FIELD_REPRESENTATIVE in that case.
    
            * g++.dg/cpp0x/variadic181.C: New test.
    
    (cherry picked from commit f8780caf07340f5d5e55cf5fb1b2be07cabab1ea)

Diff:
---
 gcc/cp/decl2.c                           | 2 +-
 gcc/testsuite/g++.dg/cpp0x/variadic181.C | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index a15bb3c45cc..672bd62f1ce 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1098,7 +1098,7 @@ grokbitfield (const cp_declarator *declarator,
 	  && !INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (TREE_TYPE (width)))
 	error ("width of bit-field %qD has non-integral type %qT", value,
 	       TREE_TYPE (width));
-      else
+      else if (!check_for_bare_parameter_packs (width))
 	{
 	  /* Temporarily stash the width in DECL_BIT_FIELD_REPRESENTATIVE.
 	     check_bitfield_decl picks it from there later and sets DECL_SIZE
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic181.C b/gcc/testsuite/g++.dg/cpp0x/variadic181.C
new file mode 100644
index 00000000000..0bb6fe7a8f3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic181.C
@@ -0,0 +1,9 @@
+// PR c++/99745
+// { dg-do compile { target c++11 } }
+
+template <typename... Ts>
+struct S { int a : sizeof(Ts); };	// { dg-error "parameter packs not expanded with '\.\.\.':" }
+S<int> s;				// { dg-message "'Ts'" "" { target *-*-* } .-1 }
+template <int... Ns>
+struct T { int a : Ns; };		// { dg-error "parameter packs not expanded with '\.\.\.':" }
+T<0> t;					// { dg-message "'Ns'" "" { target *-*-* } .-1 }


                 reply	other threads:[~2021-04-20 23:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210420233355.82E21388A837@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).