Home | History | Annotate | Download | only in SemaObjC
      1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
      2 // rdar://5986251
      3 
      4 @protocol SomeProtocol
      5 - (void) bar;
      6 @end
      7 
      8 void bar();
      9 void foo(id x) {
     10   bar((short<SomeProtocol>)x); // expected-error {{expected ')'}} expected-note {{to match this '('}}
     11   bar((<SomeProtocol>)x);      // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}
     12 
     13   [(<SomeProtocol>)x bar];      // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}
     14 }
     15 
     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).
     24 - (void)m2:(id <MyProtocol> short)arg1; // expected-error {{'short type-name' is invalid}}
     25 @end
     26 
     27 typedef int NotAnObjCObjectType;
     28 
     29 // GCC doesn't diagnose this.
     30 NotAnObjCObjectType <SomeProtocol> *obj; // expected-error {{invalid protocol qualifiers on non-ObjC type}}
     31 
     32 typedef struct objc_class *Class;
     33 
     34 Class <SomeProtocol> UnfortunateGCCExtension;
     35 
     36 // rdar://10238337
     37 @protocol Broken @end
     38 @interface Crash @end
     39 @implementation Crash
     40 - (void)crashWith:(<Broken>)a { // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}
     41 }
     42 @end
     43 
     44 typedef <SomeProtocol> id TwoTypeSpecs; // expected-warning{{no object type specified}}
     45 // expected-error@-1{{typedef redefinition with different types ('id<SomeProtocol>' vs 'id')}}
     46 // expected-error@-2{{expected ';' after top level declarator}}
     47