Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -verify |
Steve Naroff | 63359c8 | 2009-02-20 17:57:11 +0000 | [diff] [blame] | 2 | |
| 3 | @interface X |
| 4 | { |
| 5 | int a : -1; // expected-error{{bit-field 'a' has negative width}} |
| 6 | |
| 7 | // rdar://6081627 |
| 8 | int b : 33; // expected-error{{size of bit-field 'b' exceeds size of its type (32 bits)}} |
| 9 | |
| 10 | int c : (1 + 0.25); // expected-error{{expression is not an integer constant expression}} |
| 11 | int d : (int)(1 + 0.25); |
| 12 | |
| 13 | // rdar://6138816 |
| 14 | int e : 0; // expected-error {{bit-field 'e' has zero width}} |
| 15 | } |
| 16 | @end |
| 17 | |
Steve Naroff | ca33129 | 2009-03-03 14:49:36 +0000 | [diff] [blame] | 18 | @interface Base { |
| 19 | int i; |
| 20 | } |
| 21 | @end |
| 22 | |
Anders Carlsson | 31fddcc | 2009-09-14 22:00:20 +0000 | [diff] [blame] | 23 | @interface WithBitFields: Base { |
Steve Naroff | ca33129 | 2009-03-03 14:49:36 +0000 | [diff] [blame] | 24 | void *isa; // expected-note {{previous definition is here}} |
| 25 | unsigned a: 5; |
| 26 | signed b: 4; |
| 27 | int c: 5; // expected-note {{previous definition is here}} |
| 28 | } |
| 29 | @end |
| 30 | |
Anders Carlsson | 31fddcc | 2009-09-14 22:00:20 +0000 | [diff] [blame] | 31 | @implementation WithBitFields { |
Steve Naroff | ca33129 | 2009-03-03 14:49:36 +0000 | [diff] [blame] | 32 | char *isa; // expected-error {{instance variable 'isa' has conflicting type: 'char *' vs 'void *'}} |
| 33 | unsigned a: 5; |
| 34 | signed b: 4; |
Anders Carlsson | 31fddcc | 2009-09-14 22:00:20 +0000 | [diff] [blame] | 35 | int c: 3; // expected-error {{instance variable 'c' has conflicting bit-field width}} |
Steve Naroff | ca33129 | 2009-03-03 14:49:36 +0000 | [diff] [blame] | 36 | } |
| 37 | @end |