blob: 526a225ff2c8bf4231c94997d36b11fdf99b8277 [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc %s -fsyntax-only -verify
Douglas Gregora03aca82009-03-10 21:58:27 +00002enum e0; // expected-note{{forward declaration of 'enum e0'}}
Anders Carlsson9f1e5722008-12-06 20:33:04 +00003
4struct a {
5 int a : -1; // expected-error{{bit-field 'a' has negative width}}
Chris Lattnerf62e14d2008-12-11 23:11:52 +00006
7 // rdar://6081627
Anders Carlsson9f1e5722008-12-06 20:33:04 +00008 int b : 33; // expected-error{{size of bit-field 'b' exceeds size of its type (32 bits)}}
Chris Lattnerf62e14d2008-12-11 23:11:52 +00009
Anders Carlsson9f1e5722008-12-06 20:33:04 +000010 int c : (1 + 0.25); // expected-error{{expression is not an integer constant expression}}
11 int d : (int)(1 + 0.25);
Chris Lattnercd087072008-12-12 04:56:04 +000012
13 // rdar://6138816
14 int e : 0; // expected-error {{bit-field 'e' has zero width}}
Chris Lattner24793662009-03-05 22:45:59 +000015
16 float xx : 4; // expected-error {{bit-field 'xx' has non-integral type}}
17
18 // PR3607
19 enum e0 f : 1; // expected-error {{field has incomplete type 'enum e0'}}
Anders Carlssonf257b612009-03-16 18:19:21 +000020
21 int g : (_Bool)1;
Chris Lattnerdf9bcd52009-04-20 17:29:38 +000022
23 // PR4017
24 char : 10; // expected-error {{size of anonymous bitfield exceeds size of its type (8 bits)}}
25 unsigned : -2; // expected-error {{anonymous bit-field has negative width (-2)}}
26 float : 12; // expected-error {{anonymous bit-field has non-integral type 'float'}}
Anders Carlsson9f1e5722008-12-06 20:33:04 +000027};
Douglas Gregorfc24e442009-05-01 20:41:21 +000028
29struct b {unsigned x : 2;} x;
30__typeof__(x.x+1) y;
31int y;
Douglas Gregor2d833e32009-05-02 00:36:19 +000032
33struct {unsigned x : 2;} x2;
34// FIXME: __typeof__((x.x+=1)+1) y;
35__typeof__(x.x<<1) y;
36int y;