blob: 788edf276d7bf81a6c8a80ea959032c878ca8638 [file] [log] [blame]
Patrick Beardb2f68202012-04-06 18:12:22 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
Chris Lattner62f5f7f2008-07-26 00:46:50 +00002// rdar://5986251
Chris Lattnerbce61352008-07-26 00:20:22 +00003
4@protocol SomeProtocol
Chris Lattner62f5f7f2008-07-26 00:46:50 +00005- (void) bar;
Chris Lattnerbce61352008-07-26 00:20:22 +00006@end
7
Chris Lattnere0303582010-01-09 20:43:19 +00008void bar();
Chris Lattnerbce61352008-07-26 00:20:22 +00009void foo(id x) {
Chris Lattner28eb7e92008-11-23 23:17:07 +000010 bar((short<SomeProtocol>)x); // expected-error {{expected ')'}} expected-note {{to match this '('}}
Fariborz Jahaniand1084f62013-02-28 23:16:39 +000011 bar((<SomeProtocol>)x); // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}
Chris Lattner62f5f7f2008-07-26 00:46:50 +000012
Fariborz Jahaniand1084f62013-02-28 23:16:39 +000013 [(<SomeProtocol>)x bar]; // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}
Chris Lattnerbce61352008-07-26 00:20:22 +000014}
15
Steve Naroff4f9b9f12008-09-22 10:28:57 +000016@protocol MyProtocol
17- (void)doSomething;
18@end
19
20@interface MyClass
21- (void)m1:(id <MyProtocol> const)arg1;
22
23// FIXME: provide a better diagnostic (no typedef).
Douglas Gregor1a51b4a2009-02-09 15:09:02 +000024- (void)m2:(id <MyProtocol> short)arg1; // expected-error {{'short type-name' is invalid}}
Steve Naroff8dfb0c52009-02-21 19:50:43 +000025@end
26
27typedef int NotAnObjCObjectType;
28
29// GCC doesn't diagnose this.
Steve Naroff4262a072009-02-23 18:53:24 +000030NotAnObjCObjectType <SomeProtocol> *obj; // expected-error {{invalid protocol qualifiers on non-ObjC type}}
31
Steve Naroff4262a072009-02-23 18:53:24 +000032typedef struct objc_class *Class;
33
Steve Naroff470301b2009-07-22 16:07:01 +000034Class <SomeProtocol> UnfortunateGCCExtension;
Steve Naroff4262a072009-02-23 18:53:24 +000035
Argyrios Kyrtzidis0d940942011-10-05 21:28:06 +000036// rdar://10238337
37@protocol Broken @end
38@interface Crash @end
39@implementation Crash
Fariborz Jahaniand1084f62013-02-28 23:16:39 +000040- (void)crashWith:(<Broken>)a { // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}
Argyrios Kyrtzidis0d940942011-10-05 21:28:06 +000041}
42@end