Bug 57773 - -Wpedantic incorrect warning for enum bit-field
Summary: -Wpedantic incorrect warning for enum bit-field
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.8.1
: P3 normal
Target Milestone: ---
Assignee: Marek Polacek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-02 05:15 UTC by Paul Eggert
Modified: 2014-01-06 18:53 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-07-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Eggert 2013-07-02 05:15:15 UTC
Given this program in the file t.c:

  enum e { zero };
  struct { enum e field: 2; } s;

The command "gcc -Wpedantic -S t.c" outputs:

  t.c:2:15: warning: type of bit-field 'field' is a GCC extension [-Wpedantic]
  struct { enum e field: 2; } s;

This diagnostic should not be output.  -Wpedantic is supposed to
generate only diagnostics required by the standard.  But this
diagnostic is not required by C99 or by C11, since these standards
allow this GCC extension and do not require a diagnostic if the
extension is used.  And the diagnostic is not required by C89 since no
constraint is violated.
Comment 1 Marek Polacek 2013-07-05 16:43:31 UTC
Yeah, I think you're right.  Confirmed.
Comment 2 Marek Polacek 2014-01-03 14:11:01 UTC
After all, I think it'd be wise to keep the warning for ISO C, but turn if off for C99/C11.  I have a patch for that.
Comment 3 Marek Polacek 2014-01-06 18:53:03 UTC
Author: mpolacek
Date: Mon Jan  6 18:53:01 2014
New Revision: 206373

URL: http://gcc.gnu.org/viewcvs?rev=206373&root=gcc&view=rev
Log:
	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.

Added:
    trunk/gcc/testsuite/gcc.dg/pr57773.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-decl.c
    trunk/gcc/doc/implement-c.texi
    trunk/gcc/testsuite/ChangeLog
Comment 4 Marek Polacek 2014-01-06 18:53:54 UTC
Fixed.