1*67e74705SXin Li// RUN: %clang_cc1 -pedantic -verify %s 2*67e74705SXin Li// RUN: cp %s %t 3*67e74705SXin Li// RUN: not %clang_cc1 -pedantic -fixit -x objective-c %t 4*67e74705SXin Li// RUN: %clang_cc1 -pedantic -Werror -x objective-c %t 5*67e74705SXin Li 6*67e74705SXin Li/* This is a test of the various code modification hints that are 7*67e74705SXin Li provided as part of warning or extension diagnostics. All of the 8*67e74705SXin Li warnings will be fixed by -fixit, and the resulting file should 9*67e74705SXin Li compile cleanly with -Werror -pedantic. */ 10*67e74705SXin Li 11*67e74705SXin Li@protocol X; 12*67e74705SXin Li 13*67e74705SXin Livoid foo() { 14*67e74705SXin Li <X> *P; // expected-warning{{protocol has no object type specified; defaults to qualified 'id'}} 15*67e74705SXin Li} 16*67e74705SXin Li 17*67e74705SXin Li@class A; 18*67e74705SXin Li@class NSString; 19*67e74705SXin Li 20*67e74705SXin Li@interface Test 21*67e74705SXin Li- (void)test:(NSString *)string; 22*67e74705SXin Li 23*67e74705SXin Li@property (copy) NSString *property; 24*67e74705SXin Li@end 25*67e74705SXin Li 26*67e74705SXin Livoid g(NSString *a); 27*67e74705SXin Livoid h(id a); 28*67e74705SXin Li 29*67e74705SXin Livoid f(Test *t) { 30*67e74705SXin Li NSString *a = "Foo"; // expected-error {{string literal must be prefixed by '@'}} 31*67e74705SXin Li id b = "Foo"; // expected-error {{string literal must be prefixed by '@'}} 32*67e74705SXin Li g("Foo"); // expected-error {{string literal must be prefixed by '@'}} 33*67e74705SXin Li h("Foo"); // expected-error {{string literal must be prefixed by '@'}} 34*67e74705SXin Li h(("Foo")); // expected-error {{string literal must be prefixed by '@'}} 35*67e74705SXin Li [t test:"Foo"]; // expected-error {{string literal must be prefixed by '@'}} 36*67e74705SXin Li t.property = "Foo"; // expected-error {{string literal must be prefixed by '@'}} 37*67e74705SXin Li 38*67e74705SXin Li // <rdar://problem/6896493> 39*67e74705SXin Li [t test:@"Foo"]]; // expected-error{{extraneous ']' before ';'}} 40*67e74705SXin Li g(@"Foo")); // expected-error{{extraneous ')' before ';'}} 41*67e74705SXin Li} 42*67e74705SXin Li 43*67e74705SXin Li// rdar://7861841 44*67e74705SXin Li@interface Radar7861841 { 45*67e74705SXin Li@public 46*67e74705SXin Li int x; 47*67e74705SXin Li} 48*67e74705SXin Li 49*67e74705SXin Li@property (assign) int y; 50*67e74705SXin Li@end 51*67e74705SXin Li 52*67e74705SXin Liint f0(Radar7861841 *a) { return a.x; } // expected-error {{property 'x' not found on object of type 'Radar7861841 *'; did you mean to access instance variable 'x'}} 53*67e74705SXin Li 54*67e74705SXin Liint f1(Radar7861841 *a) { return a->y; } // expected-error {{property 'y' found on object of type 'Radar7861841 *'; did you mean to access it with the "." operator?}} 55*67e74705SXin Li 56*67e74705SXin Li 57*67e74705SXin Li#define nil ((void*)0) 58*67e74705SXin Li#define NULL ((void*)0) 59*67e74705SXin Li 60*67e74705SXin Livoid sentinel(int x, ...) __attribute__((sentinel)); // expected-note{{function has been explicitly marked sentinel here}} 61*67e74705SXin Li 62*67e74705SXin Li@interface Sentinel 63*67e74705SXin Li- (void)sentinel:(int)x, ... __attribute__((sentinel)); // expected-note{{method has been explicitly marked sentinel here}} 64*67e74705SXin Li@end 65*67e74705SXin Li 66*67e74705SXin Livoid sentinel_test(Sentinel *a) { 67*67e74705SXin Li sentinel(1, 2, 3); // expected-warning{{missing sentinel in function call}} 68*67e74705SXin Li [a sentinel:1, 2, 3]; // expected-warning{{missing sentinel in method dispatch}} 69*67e74705SXin Li} 70*67e74705SXin Li 71*67e74705SXin Li@interface A 72*67e74705SXin Li@property (class) int c; 73*67e74705SXin Li@end 74*67e74705SXin Li 75*67e74705SXin Liint test(A *a) { 76*67e74705SXin Li return a.c; // expected-error {{property 'c' is a class property; did you mean to access it with class 'A'}} 77*67e74705SXin Li} 78