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