From: Alex Denisov <1101.debian@gmail.com> Date: Tue, 17 Feb 2015 06:43:10 +0000 (+0000) Subject: Add more tests for NSArray/NSDictionary literals X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51b718176666845a7510828ac3bfada4697abc99;p=clang Add more tests for NSArray/NSDictionary literals git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229470 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/SemaObjC/objc-array-literal.m b/test/SemaObjC/objc-array-literal.m index 706207df74..2971fcc453 100644 --- a/test/SemaObjC/objc-array-literal.m +++ b/test/SemaObjC/objc-array-literal.m @@ -9,6 +9,18 @@ typedef unsigned long NSUInteger; typedef unsigned int NSUInteger; #endif +void checkNSArrayUnavailableDiagnostic() { + id obj; + id arr = @[obj]; // expected-error {{NSArray must be available to use Objective-C array literals}} +} + +@class NSArray; + +void checkNSArrayFDDiagnostic() { + id obj; + id arr = @[obj]; // expected-error {{declaration of 'arrayWithObjects:count:' is missing in NSArray class}} +} + @class NSString; extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); diff --git a/test/SemaObjC/objc-dictionary-literal.m b/test/SemaObjC/objc-dictionary-literal.m index f9fd57f2da..87f127f928 100644 --- a/test/SemaObjC/objc-dictionary-literal.m +++ b/test/SemaObjC/objc-dictionary-literal.m @@ -5,6 +5,20 @@ #define nil ((void *)0) +void checkNSDictionaryUnavailableDiagnostic() { + id key; + id value; + id dict = @{ key : value }; // expected-error {{NSDictionary must be available to use Objective-C dictionary literals}} +} + +@class NSDictionary; + +void checkNSDictionaryFDDiagnostic() { + id key; + id value; + id dic = @{ key : value }; // expected-error {{declaration of 'dictionaryWithObjects:forKeys:count:' is missing in NSDictionary class}} +} + @interface NSNumber + (NSNumber *)numberWithChar:(char)value; + (NSNumber *)numberWithInt:(int)value;