blob: 3e70c05096524f6300ad8fc86e9bcf6ab2fb312d [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %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
8void foo(id x) {
Chris Lattner28eb7e92008-11-23 23:17:07 +00009 bar((short<SomeProtocol>)x); // expected-error {{expected ')'}} expected-note {{to match this '('}}
Chris Lattnerbce61352008-07-26 00:20:22 +000010 bar((<SomeProtocol>)x); // expected-warning {{protocol qualifiers without 'id' is archaic}}
Chris Lattner62f5f7f2008-07-26 00:46:50 +000011
12 [(<SomeProtocol>)x bar]; // expected-warning {{protocol qualifiers without 'id' is archaic}}
Chris Lattnerbce61352008-07-26 00:20:22 +000013}
14
Steve Naroff4f9b9f12008-09-22 10:28:57 +000015@protocol MyProtocol
16- (void)doSomething;
17@end
18
19@interface MyClass
20- (void)m1:(id <MyProtocol> const)arg1;
21
22// FIXME: provide a better diagnostic (no typedef).
Douglas Gregor1a51b4a2009-02-09 15:09:02 +000023- (void)m2:(id <MyProtocol> short)arg1; // expected-error {{'short type-name' is invalid}}
Steve Naroff8dfb0c52009-02-21 19:50:43 +000024@end
25
26typedef int NotAnObjCObjectType;
27
28// GCC doesn't diagnose this.
Steve Naroff4262a072009-02-23 18:53:24 +000029NotAnObjCObjectType <SomeProtocol> *obj; // expected-error {{invalid protocol qualifiers on non-ObjC type}}
30
31// Decided not to support the following GCC extension. Found while researching rdar://6497631
32typedef struct objc_class *Class;
33
34Class <SomeProtocol> UnfortunateGCCExtension; // expected-error {{protocol qualified 'Class' is unsupported}}
35