xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/class-bitfield.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 %s -fobjc-runtime=macosx-fragile-10.5 -fsyntax-only -verify
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc@interface X
4*f4a2713aSLionel Sambuc{
5*f4a2713aSLionel Sambuc  int a : -1; // expected-error{{bit-field 'a' has negative width}}
6*f4a2713aSLionel Sambuc
7*f4a2713aSLionel Sambuc  // rdar://6081627
8*f4a2713aSLionel Sambuc  int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambuc  int c : (1 + 0.25); // expected-error{{expression is not an integer constant expression}}
11*f4a2713aSLionel Sambuc  int d : (int)(1 + 0.25);
12*f4a2713aSLionel Sambuc
13*f4a2713aSLionel Sambuc  // rdar://6138816
14*f4a2713aSLionel Sambuc  int e : 0;  // expected-error {{bit-field 'e' has zero width}}
15*f4a2713aSLionel Sambuc}
16*f4a2713aSLionel Sambuc@end
17*f4a2713aSLionel Sambuc
18*f4a2713aSLionel Sambuc@interface Base {
19*f4a2713aSLionel Sambuc  int i;
20*f4a2713aSLionel Sambuc}
21*f4a2713aSLionel Sambuc@end
22*f4a2713aSLionel Sambuc
23*f4a2713aSLionel Sambuc@interface WithBitFields: Base {
24*f4a2713aSLionel Sambuc  void *isa; // expected-note {{previous definition is here}}
25*f4a2713aSLionel Sambuc  unsigned a: 5;
26*f4a2713aSLionel Sambuc  signed b: 4;
27*f4a2713aSLionel Sambuc  int c: 5; // expected-note {{previous definition is here}}
28*f4a2713aSLionel Sambuc}
29*f4a2713aSLionel Sambuc@end
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambuc@implementation WithBitFields {
32*f4a2713aSLionel Sambuc  char *isa;  // expected-error {{instance variable 'isa' has conflicting type: 'char *' vs 'void *'}}
33*f4a2713aSLionel Sambuc  unsigned a: 5;
34*f4a2713aSLionel Sambuc  signed b: 4;
35*f4a2713aSLionel Sambuc  int c: 3;  // expected-error {{instance variable 'c' has conflicting bit-field width}}
36*f4a2713aSLionel Sambuc}
37*f4a2713aSLionel Sambuc@end
38