Bug report: http://llvm.org/bugs/show_bug.cgi?id=22561
Clang tries to create ObjCBoxedExpression of type 'NSNumber'
when 'NSNumber' has only forward declaration, this cause a crash later,
when 'Sema' refers to a nil QualType of the whole expression.
Please, refer to the bug report for the better explanation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229402
91177308-0d34-0410-b5e6-
96231b3b80d8
S.Diag(Loc, diag::err_undeclared_nsnumber);
return nullptr;
}
-
+ }
+
+ if (S.NSNumberPointer.isNull()) {
// generate the pointer to NSNumber type.
QualType NSNumberObject = CX.getObjCInterfaceType(S.NSNumberDecl);
S.NSNumberPointer = CX.getObjCObjectPointerType(NSNumberObject);
typedef int NSInteger;
#endif
+void checkNSNumberUnavailableDiagnostic() {
+ id num = @1000; // expected-error {{NSNumber must be available to use Objective-C literals}}
+
+ int x = 1000;
+ id num1 = @(x); // expected-error {{NSNumber must be available to use Objective-C literals}}\
+ // expected-error {{illegal type 'int' used in a boxed expression}}
+}
+
+@class NSNumber;
+
+void checkNSNumberFDDiagnostic() {
+ id num = @1000; // expected-error {{NSNumber must be available to use Objective-C literals}}
+
+ int x = 1000;
+ id num1 = @(x); // expected-error {{declaration of 'numberWithInt:' is missing in NSNumber class}}\
+ // expected-error {{illegal type 'int' used in a boxed expression}}
+}
+
@interface NSObject
+ (NSObject*)nsobject;
@end