On Fri, Jan 03, 2014 at 05:17:28PM +0000, Joseph S. Myers wrote:
> Implementation-defined behavior is documented in implement-c.texi, so this 
> patch is incomplete as it doesn't update that file where it says:
> 
>     No other types are permitted in strictly conforming mode.
>     @c Would it be better to restrict the pedwarn for other types to C90
>     @c mode and document the other types for C99/C11 mode?

Sorry for missing this one.
 
> (And this isn't just about enums, but other integer types as well, so the 
> test should cover those.)

I've put some more types in the test.

Ok now?  Thanks,

2014-01-06  Marek Polacek  <pola...@redhat.com>

        PR c/57773
        * doc/implement-c.texi: Mention that other integer types are
        permitted as bit-field types in strictly conforming mode.
c/
        * c-decl.c (check_bitfield_type_and_width): Warn for implementation
        defined bit-field types only in ISO C.
testsuite/
        * gcc.dg/pr57773.c: New test.

--- gcc/doc/implement-c.texi.mp 2014-01-03 18:22:47.320742545 +0100
+++ gcc/doc/implement-c.texi    2014-01-06 12:34:02.280756348 +0100
@@ -479,9 +479,8 @@ by the @option{-funsigned-bitfields} opt
 @cite{Allowable bit-field types other than @code{_Bool}, @code{signed int},
 and @code{unsigned int} (C99 and C11 6.7.2.1).}
 
-No other types are permitted in strictly conforming mode.
-@c Would it be better to restrict the pedwarn for other types to C90
-@c mode and document the other types for C99/C11 mode?
+Other integer types, such as @code{long int}, and enumerated types are
+permitted even in strictly conforming mode.
 
 @item
 @cite{Whether atomic types are permitted for bit-fields (C11 6.7.2.1).}
--- gcc/c/c-decl.c.mp   2014-01-03 13:50:37.041997222 +0100
+++ gcc/c/c-decl.c      2014-01-03 14:46:29.115816235 +0100
@@ -4840,7 +4840,8 @@ check_bitfield_type_and_width (tree *typ
   if (!in_system_header_at (input_location)
       && type_mv != integer_type_node
       && type_mv != unsigned_type_node
-      && type_mv != boolean_type_node)
+      && type_mv != boolean_type_node
+      && !flag_isoc99)
     pedwarn (input_location, OPT_Wpedantic,
             "type of bit-field %qs is a GCC extension", name);
 
--- gcc/testsuite/gcc.dg/pr57773.c.mp   2014-01-03 14:50:51.097902818 +0100
+++ gcc/testsuite/gcc.dg/pr57773.c      2014-01-06 12:34:24.000000000 +0100
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c99 -Wpedantic" } */
+
+enum e { A };
+struct { enum e b: 2; } s1;
+struct { signed char b: 2; } s2;
+struct { unsigned char b: 2; } s3;
+struct { short b: 2; } s4;
+struct { unsigned short b: 2; } s5;
+struct { long int b: 2; } s6;
+struct { unsigned long int b: 2; } s7;
+struct { long long int b: 2; } s8;
+struct { unsigned long long int b: 2; } s9;

        Marek

Reply via email to