Hi!

The following invalid tests ICE because we don't diagnose (and drop) bare
parameter packs in bitfield widths.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2021-03-24  Jakub Jelinek  <ja...@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.

--- gcc/cp/decl2.c.jj   2021-03-23 16:14:01.765300278 +0100
+++ gcc/cp/decl2.c      2021-03-24 16:30:30.635890413 +0100
@@ -1117,7 +1117,7 @@ grokbitfield (const cp_declarator *decla
          && !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
--- gcc/testsuite/g++.dg/cpp0x/variadic181.C.jj 2021-03-24 16:40:38.063294626 
+0100
+++ gcc/testsuite/g++.dg/cpp0x/variadic181.C    2021-03-24 16:42:46.494901686 
+0100
@@ -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 }

        Jakub

Reply via email to