brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · ffb04ff Raw
45 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-pointer-to-int-cast -Wno-objc-root-class -Wno-strict-prototypes %s2 3@protocol SomeProtocol4- (void) bar;5@end6 7void bar();8void foo(id x) {9  bar((short<SomeProtocol>)x); // expected-error {{expected ')'}} expected-note {{to match this '('}}10  bar((<SomeProtocol>)x);      // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}11 12  [(<SomeProtocol>)x bar];      // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}13}14 15@protocol MyProtocol16- (void)doSomething;17@end18 19@interface MyClass20- (void)m1:(id <MyProtocol> const)arg1;21 22// FIXME: provide a better diagnostic (no typedef).23- (void)m2:(id <MyProtocol> short)arg1; // expected-error {{'short type-name' is invalid}}24@end25 26typedef int NotAnObjCObjectType;27 28// GCC doesn't diagnose this.29NotAnObjCObjectType <SomeProtocol> *obj; // expected-error {{invalid protocol qualifiers on non-ObjC type}}30 31typedef struct objc_class *Class;32 33Class <SomeProtocol> UnfortunateGCCExtension;34 35@protocol Broken @end36@interface Crash @end37@implementation Crash38- (void)crashWith:(<Broken>)a { // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}39}40@end41 42typedef <SomeProtocol> id TwoTypeSpecs; // expected-warning{{no object type specified}}43// expected-error@-1{{typedef redefinition with different types ('id<SomeProtocol>' vs 'id')}}44// expected-error@-2{{expected ';' after top level declarator}}45