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.
8 /* { dg-options "-pedantic -std=gnu89" } */
10 enum foo
{e1
= 0, e2
, e3
, e4
, e5
};
13 typedef unsigned int ui
;
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" } */
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" } */
27 enum foo i
: 2; /* { dg-warning "narrower" } */
28 /* { dg-warning "GCC extension|ISO C" "extension" { target *-*-* } .-1 } */
29 enum foo j
: 3; /* { dg-warning "GCC extension|ISO C" } */
30 unsigned int k
: 256; /* { dg-error "exceeds its type" } */