2012-03-29 01:56:49 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
|
|
// rdar://11062080
|
2013-11-02 05:58:17 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -triple i386-apple-macosx10.9.0 -fobjc-runtime=macosx-fragile-10.9.0 -fobjc-subscripting-legacy-runtime -verify %s
|
|
|
|
// rdar://15363492
|
2012-03-29 01:56:49 +08:00
|
|
|
|
2014-09-11 04:55:31 +08:00
|
|
|
#define nil ((void *)0)
|
|
|
|
|
2015-02-17 14:43:10 +08:00
|
|
|
void checkNSDictionaryUnavailableDiagnostic() {
|
|
|
|
id key;
|
|
|
|
id value;
|
2015-07-24 13:09:40 +08:00
|
|
|
id dict = @{ key : value }; // expected-error {{definition of class NSDictionary must be available to use Objective-C dictionary literals}}
|
2015-02-17 14:43:10 +08:00
|
|
|
}
|
|
|
|
|
2015-07-24 13:09:40 +08:00
|
|
|
@class NSDictionary; // expected-note {{forward declaration of class here}}
|
2015-02-17 14:43:10 +08:00
|
|
|
|
|
|
|
void checkNSDictionaryFDDiagnostic() {
|
|
|
|
id key;
|
|
|
|
id value;
|
2015-07-24 13:09:40 +08:00
|
|
|
id dic = @{ key : value }; // expected-error {{definition of class NSDictionary must be available to use Objective-C dictionary literals}}
|
2015-02-17 14:43:10 +08:00
|
|
|
}
|
|
|
|
|
2012-03-29 01:56:49 +08:00
|
|
|
@interface NSNumber
|
|
|
|
+ (NSNumber *)numberWithChar:(char)value;
|
|
|
|
+ (NSNumber *)numberWithInt:(int)value;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@protocol NSCopying @end
|
|
|
|
typedef unsigned long NSUInteger;
|
|
|
|
typedef long NSInteger;
|
|
|
|
|
|
|
|
@interface NSDictionary
|
|
|
|
+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
|
|
|
|
- (void)setObject:(id)object forKeyedSubscript:(id)key;
|
2014-09-11 04:55:31 +08:00
|
|
|
- (id)objectForKeyedSubscript:(id)key;
|
2012-03-29 01:56:49 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface NSString<NSCopying>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface NSArray
|
|
|
|
- (id)objectAtIndexedSubscript:(NSInteger)index;
|
|
|
|
- (void)setObject:(id)object atIndexedSubscript:(NSInteger)index;
|
|
|
|
@end
|
|
|
|
|
2014-09-11 06:12:13 +08:00
|
|
|
void *pvoid;
|
2012-03-29 01:56:49 +08:00
|
|
|
int main() {
|
|
|
|
NSDictionary *dict = @{ @"name":@666 };
|
|
|
|
dict[@"name"] = @666;
|
|
|
|
|
2012-07-20 02:10:18 +08:00
|
|
|
dict["name"] = @666; // expected-error {{indexing expression is invalid because subscript type 'char *' is not an Objective-C pointer}}
|
2012-03-29 01:56:49 +08:00
|
|
|
|
2014-09-11 04:55:31 +08:00
|
|
|
// rdar://18254621
|
|
|
|
[@{@"foo" : @"bar"} objectForKeyedSubscript:nil];
|
|
|
|
(void)@{@"foo" : @"bar"}[nil];
|
2014-09-11 06:12:13 +08:00
|
|
|
[@{@"foo" : @"bar"} objectForKeyedSubscript:pvoid];
|
|
|
|
(void)@{@"foo" : @"bar"}[pvoid];
|
2014-09-11 04:55:31 +08:00
|
|
|
|
|
|
|
[@{@"foo" : @"bar"} setObject:nil forKeyedSubscript:@"gorf"];
|
|
|
|
@{@"foo" : @"bar"}[nil] = @"gorf";
|
2014-09-11 06:12:13 +08:00
|
|
|
[@{@"foo" : @"bar"} setObject:pvoid forKeyedSubscript:@"gorf"];
|
|
|
|
@{@"foo" : @"bar"}[pvoid] = @"gorf";
|
2014-09-11 04:55:31 +08:00
|
|
|
|
2012-03-29 01:56:49 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-20 04:21:18 +08:00
|
|
|
enum XXXYYYZZZType { XXXYYYZZZTypeAny }; // expected-note {{'XXXYYYZZZTypeAny' declared here}}
|
|
|
|
void foo() {
|
|
|
|
NSDictionary *d = @{
|
|
|
|
@"A" : @(XXXYYYZZZTypeA), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeA'; did you mean 'XXXYYYZZZTypeAny'}}
|
|
|
|
@"F" : @(XXXYYYZZZTypeSomethingSomething), // expected-error {{use of undeclared identifier 'XXXYYYZZZTypeSomethingSomething'}}
|
|
|
|
};
|
|
|
|
}
|