blob: 655f74121a32126a2618777d44d927b82d365865 [file] [log] [blame]
Daniel Dunbarffd408a2009-03-24 02:24:46 +00001// RUN: clang-cc %s -fsyntax-only -verify
Douglas Gregor3dc4b322009-03-10 21:58:27 +00002enum e0; // expected-note{{forward declaration of 'enum e0'}}
Anders Carlsson108229a2008-12-06 20:33:04 +00003
4struct a {
5 int a : -1; // expected-error{{bit-field 'a' has negative width}}
Chris Lattner76eb2c52008-12-11 23:11:52 +00006
7 // rdar://6081627
Anders Carlsson108229a2008-12-06 20:33:04 +00008 int b : 33; // expected-error{{size of bit-field 'b' exceeds size of its type (32 bits)}}
Chris Lattner76eb2c52008-12-11 23:11:52 +00009
Anders Carlsson108229a2008-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 Lattner8464c372008-12-12 04:56:04 +000012
13 // rdar://6138816
14 int e : 0; // expected-error {{bit-field 'e' has zero width}}
Chris Lattner9cffefc2009-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 Carlssond9e643a2009-03-16 18:19:21 +000020
21 int g : (_Bool)1;
Chris Lattnercfe51572009-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 Carlsson108229a2008-12-06 20:33:04 +000027};
Douglas Gregor70b307e2009-05-01 20:41:21 +000028
29struct b {unsigned x : 2;} x;
30__typeof__(x.x+1) y;
31int y;
Douglas Gregor6fcf2ca2009-05-02 00:36:19 +000032
33struct {unsigned x : 2;} x2;
Douglas Gregor531434b2009-05-02 02:18:30 +000034__typeof__((x.x+=1)+1) y;
Douglas Gregor6fcf2ca2009-05-02 00:36:19 +000035__typeof__(x.x<<1) y;
36int y;