Patrick Beard | b2f6820 | 2012-04-06 18:12:22 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s |
Chris Lattner | 62f5f7f | 2008-07-26 00:46:50 +0000 | [diff] [blame] | 2 | // rdar://5986251 |
Chris Lattner | bce6135 | 2008-07-26 00:20:22 +0000 | [diff] [blame] | 3 | |
| 4 | @protocol SomeProtocol |
Chris Lattner | 62f5f7f | 2008-07-26 00:46:50 +0000 | [diff] [blame] | 5 | - (void) bar; |
Chris Lattner | bce6135 | 2008-07-26 00:20:22 +0000 | [diff] [blame] | 6 | @end |
| 7 | |
Chris Lattner | e030358 | 2010-01-09 20:43:19 +0000 | [diff] [blame] | 8 | void bar(); |
Chris Lattner | bce6135 | 2008-07-26 00:20:22 +0000 | [diff] [blame] | 9 | void foo(id x) { |
Chris Lattner | 28eb7e9 | 2008-11-23 23:17:07 +0000 | [diff] [blame] | 10 | bar((short<SomeProtocol>)x); // expected-error {{expected ')'}} expected-note {{to match this '('}} |
Fariborz Jahanian | d1084f6 | 2013-02-28 23:16:39 +0000 | [diff] [blame] | 11 | bar((<SomeProtocol>)x); // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}} |
Chris Lattner | 62f5f7f | 2008-07-26 00:46:50 +0000 | [diff] [blame] | 12 | |
Fariborz Jahanian | d1084f6 | 2013-02-28 23:16:39 +0000 | [diff] [blame] | 13 | [(<SomeProtocol>)x bar]; // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}} |
Chris Lattner | bce6135 | 2008-07-26 00:20:22 +0000 | [diff] [blame] | 14 | } |
| 15 | |
Steve Naroff | 4f9b9f1 | 2008-09-22 10:28:57 +0000 | [diff] [blame] | 16 | @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 Gregor | 1a51b4a | 2009-02-09 15:09:02 +0000 | [diff] [blame] | 24 | - (void)m2:(id <MyProtocol> short)arg1; // expected-error {{'short type-name' is invalid}} |
Steve Naroff | 8dfb0c5 | 2009-02-21 19:50:43 +0000 | [diff] [blame] | 25 | @end |
| 26 | |
| 27 | typedef int NotAnObjCObjectType; |
| 28 | |
| 29 | // GCC doesn't diagnose this. |
Steve Naroff | 4262a07 | 2009-02-23 18:53:24 +0000 | [diff] [blame] | 30 | NotAnObjCObjectType <SomeProtocol> *obj; // expected-error {{invalid protocol qualifiers on non-ObjC type}} |
| 31 | |
Steve Naroff | 4262a07 | 2009-02-23 18:53:24 +0000 | [diff] [blame] | 32 | typedef struct objc_class *Class; |
| 33 | |
Steve Naroff | 470301b | 2009-07-22 16:07:01 +0000 | [diff] [blame] | 34 | Class <SomeProtocol> UnfortunateGCCExtension; |
Steve Naroff | 4262a07 | 2009-02-23 18:53:24 +0000 | [diff] [blame] | 35 | |
Argyrios Kyrtzidis | 0d94094 | 2011-10-05 21:28:06 +0000 | [diff] [blame] | 36 | // rdar://10238337 |
| 37 | @protocol Broken @end |
| 38 | @interface Crash @end |
| 39 | @implementation Crash |
Fariborz Jahanian | d1084f6 | 2013-02-28 23:16:39 +0000 | [diff] [blame] | 40 | - (void)crashWith:(<Broken>)a { // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}} |
Argyrios Kyrtzidis | 0d94094 | 2011-10-05 21:28:06 +0000 | [diff] [blame] | 41 | } |
| 42 | @end |