1 // RUN: %clang_cc1 %s -fsyntax-only -verify -std=c11 -Wno-unused-value
3 enum e0; // expected-note{{forward declaration of 'enum e0'}}
6 int a : -1; // expected-error{{bit-field 'a' has negative width}}
9 int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
11 int c : (1 + 0.25); // expected-error{{expression is not an integer constant expression}}
12 int d : (int)(1 + 0.25);
15 int e : 0; // expected-error {{bit-field 'e' has zero width}}
17 float xx : 4; // expected-error {{bit-field 'xx' has non-integral type}}
20 enum e0 f : 1; // expected-error {{field has incomplete type 'enum e0'}}
25 char : 10; // expected-error {{size of anonymous bit-field (10 bits) exceeds size of its type (8 bits)}}
26 unsigned : -2; // expected-error {{anonymous bit-field has negative width (-2)}}
27 float : 12; // expected-error {{anonymous bit-field has non-integral type 'float'}}
30 struct b {unsigned x : 2;} x;
34 struct {unsigned x : 2;} x2;
35 __typeof__((x.x+=1)+1) y;
36 __typeof__((0,x.x)+1) y;
41 double : 2; // expected-error{{anonymous bit-field has non-integral type 'double'}}
49 void test4(struct Test4 *t) {
50 (void) sizeof(t->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}}
51 (void) sizeof((t->bitY)); // expected-error {{invalid application of 'sizeof' to bit-field}}
52 (void) sizeof(t->bitX = 4); // not a bitfield designator in C
53 (void) sizeof(t->bitX += 4); // not a bitfield designator in C
54 (void) sizeof((void) 0, t->bitX); // not a bitfield designator in C
55 (void) sizeof(t->var ? t->bitX : t->bitY); // not a bitfield designator in C
56 (void) sizeof(t->var ? t->bitX : t->bitX); // not a bitfield designator in C
59 typedef unsigned Unsigned;
60 typedef signed Signed;
62 struct Test5 { unsigned n : 2; } t5;
63 typedef __typeof__(t5.n) Unsigned; // Bitfield is unsigned
64 typedef __typeof__(+t5.n) Signed; // ... but promotes to signed.
66 typedef __typeof__(t5.n + 0) Signed; // Arithmetic promotes.
68 typedef __typeof__(+(t5.n = 0)) Signed; // FIXME: Assignment should not; the result
69 typedef __typeof__(+(t5.n += 0)) Signed; // is a non-bit-field lvalue of type unsigned.
70 typedef __typeof__(+(t5.n *= 0)) Signed;
72 typedef __typeof__(+(++t5.n)) Signed; // FIXME: Increment is equivalent to compound-assignment.
73 typedef __typeof__(+(--t5.n)) Signed; // This should not promote to signed.
75 typedef __typeof__(+(t5.n++)) Unsigned; // Post-increment is underspecified, but seems to
76 typedef __typeof__(+(t5.n--)) Unsigned; // also act like compound-assignment.
79 : 0.0; // expected-error{{type name requires a specifier or qualifier}}