PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.dg / bitfld-1.c
blob246e07c58914da9c655fa2dbd3793a6c620a08f0
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 -std=gnu89" } */
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 *-*-* } .-1 } */
29 enum foo j: 3; /* { dg-warning "GCC extension|ISO C" } */
30 unsigned int k: 256; /* { dg-error "exceeds its type" } */