2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / gcc / testsuite / gcc.dg / bitfld-1.c
blobfa835f2299f69bedd6bc05af25c7660a3040fef7
1 /* Copyright (C) 2002 Free Software Foundation, Inc.
3 Tests various diagnostics about a bit-field's type and width.
5 Source: Neil Booth, 26 Jan 2002.
6 */
8 /* { dg-options -pedantic } */
10 enum foo {e1 = 0, e2, e3, e4, e5};
12 int x;
13 typedef unsigned int ui;
15 struct bf1
17 unsigned int a: 3.5; /* { dg-error "integer constant" } */
18 unsigned int b: x; /* { dg-error "integer constant" } */
19 unsigned int c: -1; /* { dg-error "negative width" } */
20 unsigned int d: 0; /* { dg-error "zero width" } */
21 unsigned int : 0; /* { dg-bogus "zero width" } */
22 unsigned int : 5;
23 double e: 1; /* { dg-error "invalid type" } */
24 float f: 1; /* { dg-error "invalid type" } */
25 unsigned long g: 5; /* { dg-warning "GCC extension|ISO C" } */
26 ui h: 5;
27 enum foo i: 2; /* { dg-warning "narrower" } */
28 /* { dg-warning "GCC extension|ISO C" "extension" { target *-*-* } 27 } */
29 enum foo j: 3; /* { dg-warning "GCC extension|ISO C" } */
30 unsigned int k: 256; /* { dg-error "exceeds its type" } */