1// RUN: %clang_cc1 -triple x86_64-apple-macos10.10 %s -verify=c,expected 2// RUN: %clang_cc1 -triple x86_64-apple-macos10.10 %s -xobjective-c++ -verify=cxx,expected 3// RUN: %clang_cc1 -triple x86_64-apple-macos10.10 %s -fobjc-arc -verify=c,arc,expected 4 5typedef signed char BOOL; 6#define YES __objc_yes 7#define NO __objc_no 8 9@interface NSNumber 10+(instancetype)numberWithChar:(char)value; 11+(instancetype)numberWithInt:(int)value; 12+(instancetype)numberWithDouble:(double)value; 13+(instancetype)numberWithBool:(BOOL)value; 14@end 15 16void test() { 17 NSNumber *n = YES; // expected-error{{numeric literal must be prefixed by '@'}} 18 NSNumber *n1 = 1; // expected-error{{numeric literal must be prefixed by '@'}} 19 20 NSNumber *n2 = NO; // c-warning{{expression which evaluates to zero treated as a null pointer constant}} 21 // cxx-error@-1{{numeric literal must be prefixed by '@'}} 22 NSNumber *n3 = 0; 23 NSNumber *n4 = 0.0; // expected-error{{numeric literal must be prefixed by '@'}} 24 25 NSNumber *n5 = '\0'; // c-warning{{expression which evaluates to zero treated as a null pointer constant}} 26 // cxx-error@-1{{numeric literal must be prefixed by '@'}} 27 28 29 NSNumber *n6 = '1'; // expected-error{{numeric literal must be prefixed by '@'}} 30 31 int i; 32 NSNumber *n7 = i; // c-warning{{incompatible integer to pointer conversion}} 33 // arc-error@-1{{implicit conversion of 'int' to 'NSNumber *' is disallowed with ARC}} 34 // cxx-error@-2{{cannot initialize a variable of type 'NSNumber *' with an lvalue of type 'int'}} 35 36 id n8 = 1; // c-warning{{incompatible integer to pointer conversion}} 37 // arc-error@-1{{implicit conversion of 'int' to 'id' is disallowed with ARC}} 38 // cxx-error@-2{{cannot initialize a variable of type 'id' with an rvalue of type 'int'}} 39} 40