111
|
1 /* Copyright (C) 2002 Free Software Foundation, Inc.
|
|
2
|
|
3 Tests various diagnostics about a bit-field's type and width.
|
|
4
|
|
5 Source: Neil Booth, 26 Jan 2002.
|
|
6 */
|
|
7
|
|
8 /* { dg-options "-pedantic -std=gnu89" } */
|
|
9
|
|
10 enum foo {e1 = 0, e2, e3, e4, e5};
|
|
11
|
|
12 int x;
|
|
13 typedef unsigned int ui;
|
|
14
|
|
15 struct bf1
|
|
16 {
|
|
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 *-*-* } .-1 } */
|
|
29 enum foo j: 3; /* { dg-warning "GCC extension|ISO C" } */
|
|
30 unsigned int k: 256; /* { dg-error "exceeds its type" } */
|
|
31 };
|