Files
clang-p2996/clang/test/SemaObjC/protocol-expr-neg-1.m
Aaron Ballman 7deaeb2a05 Use functions with prototypes when appropriate; NFC
A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the fourth batch of tests being updated (there are a significant
number of other tests left to be updated).
2022-02-07 15:29:36 -05:00

35 lines
1.1 KiB
Objective-C

// RUN: %clang_cc1 -fsyntax-only -verify %s
@class Protocol;
@protocol fproto; // expected-note {{'fproto' declared here}}
@protocol p1
@end
@class cl;
int main(void)
{
Protocol *proto = @protocol(p1);
Protocol *fproto = @protocol(fproto); // expected-error {{@protocol is using a forward protocol declaration of 'fproto'}}
Protocol *pp = @protocol(i); // expected-error {{cannot find protocol declaration for 'i'}}
Protocol *p1p = @protocol(cl); // expected-error {{cannot find protocol declaration for 'cl'}}
}
// rdar://17768630
@protocol SuperProtocol; // expected-note {{'SuperProtocol' declared here}}
@protocol TestProtocol; // expected-note {{'TestProtocol' declared here}}
@interface I
- (int) conformsToProtocol : (Protocol *)protocl;
@end
int doesConform(id foo) {
return [foo conformsToProtocol:@protocol(TestProtocol)]; // expected-error {{@protocol is using a forward protocol declaration of 'TestProtocol'}}
}
int doesConformSuper(id foo) {
return [foo conformsToProtocol:@protocol(SuperProtocol)]; // expected-error {{@protocol is using a forward protocol declaration of 'SuperProtocol'}}
}