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