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