1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s 2*f4a2713aSLionel Sambuc// rdar://5986251 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc@protocol SomeProtocol 5*f4a2713aSLionel Sambuc- (void) bar; 6*f4a2713aSLionel Sambuc@end 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambucvoid bar(); 9*f4a2713aSLionel Sambucvoid foo(id x) { 10*f4a2713aSLionel Sambuc bar((short<SomeProtocol>)x); // expected-error {{expected ')'}} expected-note {{to match this '('}} 11*f4a2713aSLionel Sambuc bar((<SomeProtocol>)x); // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}} 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc [(<SomeProtocol>)x bar]; // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}} 14*f4a2713aSLionel Sambuc} 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc@protocol MyProtocol 17*f4a2713aSLionel Sambuc- (void)doSomething; 18*f4a2713aSLionel Sambuc@end 19*f4a2713aSLionel Sambuc 20*f4a2713aSLionel Sambuc@interface MyClass 21*f4a2713aSLionel Sambuc- (void)m1:(id <MyProtocol> const)arg1; 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc// FIXME: provide a better diagnostic (no typedef). 24*f4a2713aSLionel Sambuc- (void)m2:(id <MyProtocol> short)arg1; // expected-error {{'short type-name' is invalid}} 25*f4a2713aSLionel Sambuc@end 26*f4a2713aSLionel Sambuc 27*f4a2713aSLionel Sambuctypedef int NotAnObjCObjectType; 28*f4a2713aSLionel Sambuc 29*f4a2713aSLionel Sambuc// GCC doesn't diagnose this. 30*f4a2713aSLionel SambucNotAnObjCObjectType <SomeProtocol> *obj; // expected-error {{invalid protocol qualifiers on non-ObjC type}} 31*f4a2713aSLionel Sambuc 32*f4a2713aSLionel Sambuctypedef struct objc_class *Class; 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel SambucClass <SomeProtocol> UnfortunateGCCExtension; 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc// rdar://10238337 37*f4a2713aSLionel Sambuc@protocol Broken @end 38*f4a2713aSLionel Sambuc@interface Crash @end 39*f4a2713aSLionel Sambuc@implementation Crash 40*f4a2713aSLionel Sambuc- (void)crashWith:(<Broken>)a { // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}} 41*f4a2713aSLionel Sambuc} 42*f4a2713aSLionel Sambuc@end 43