1 // RUN: %clang_cc1 %s -verify -Wobjc-signed-char-bool
2 // RUN: %clang_cc1 -xobjective-c++ %s -verify -Wobjc-signed-char-bool
4 typedef signed char BOOL;
8 typedef unsigned char Boolean;
18 b = fl; // expected-warning {{implicit conversion from floating-point type 'float' to 'BOOL'}}
19 b = i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
23 b = 1.1; // expected-warning {{implicit conversion from 'double' to 'BOOL' (aka 'signed char') changes value from 1.1 to 1}}
24 b = 2.1; // expected-warning {{implicit conversion from constant value 2.1 to 'BOOL'; the only well defined values for 'BOOL' are YES and NO}}
28 b = ptr; // expected-warning {{incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'int *'}}
36 void t2(BoolProp *bp) {
40 bp.p = fl; // expected-warning {{implicit conversion from floating-point type 'float' to 'BOOL'}}
41 bp.p = i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
45 bp.p = ptr; // expected-warning {{incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'int *'}}
48 bp.p = 2; // expected-warning {{implicit conversion from constant value 2 to 'BOOL'; the only well defined values for 'BOOL' are YES and NO}}
54 unsigned unsigned_bf1 : 1;
55 unsigned unsigned_bf2 : 2;
57 struct has_bf *nested;
60 void t3(struct has_bf *bf) {
61 b = bf->signed_bf1; // expected-warning{{implicit conversion from integral type 'int' to 'BOOL'}}
62 b = bf->signed_bf2; // expected-warning{{implicit conversion from integral type 'int' to 'BOOL'}}
63 b = bf->unsigned_bf1; // no warning
64 b = bf->unsigned_bf2; // expected-warning{{implicit conversion from integral type 'unsigned int' to 'BOOL'}}
66 b = local.unsigned_bf1;
67 b = local.unsigned_bf2; // expected-warning{{implicit conversion from integral type 'unsigned int' to 'BOOL'}}
68 b = local.nested->unsigned_bf1;
69 b = local.nested->unsigned_bf2; // expected-warning{{implicit conversion from integral type 'unsigned int' to 'BOOL'}}
72 __attribute__((objc_root_class))
75 unsigned unsigned_bf1 : 1;
76 unsigned unsigned_bf2 : 2;
80 @implementation BFIvar
83 b = bf.unsigned_bf2; // expected-warning{{implicit conversion from integral type 'unsigned int' to 'BOOL'}}
85 b = unsigned_bf2; // expected-warning{{implicit conversion from integral type 'unsigned int' to 'BOOL'}}
92 unsigned i : sizeof(T);
98 BOOL b = i.i; // expected-warning{{implicit conversion from integral type 'unsigned int' to 'BOOL'}}
103 f<short>(); // expected-note {{in instantiation of function template specialization 'f<short>' requested here}}