xref: /aosp_15_r20/external/clang/test/SemaObjC/objc-asm-attribute-neg-test.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
2*67e74705SXin Li// rdar://16462586
3*67e74705SXin Li
4*67e74705SXin Li__attribute__((objc_runtime_name)) // expected-error {{'objc_runtime_name' attribute takes one argument}}
5*67e74705SXin Li@interface BInterface
6*67e74705SXin Li@end
7*67e74705SXin Li
8*67e74705SXin Li__attribute__((objc_runtime_name(123))) // expected-error {{'objc_runtime_name' attribute requires a string}}
9*67e74705SXin Li@protocol BProtocol1
10*67e74705SXin Li@end
11*67e74705SXin Li
12*67e74705SXin Li__attribute__((objc_runtime_name("MySecretNamespace.Protocol")))
13*67e74705SXin Li@protocol Protocol
14*67e74705SXin Li@end
15*67e74705SXin Li
16*67e74705SXin Li__attribute__((objc_runtime_name("MySecretNamespace.Message")))
17*67e74705SXin Li@interface Message <Protocol> {
18*67e74705SXin Li__attribute__((objc_runtime_name("MySecretNamespace.Message"))) // expected-error {{'objc_runtime_name' attribute only applies to interface or protocol declarations}}
19*67e74705SXin Li  id MyIVAR;
20*67e74705SXin Li}
21*67e74705SXin Li__attribute__((objc_runtime_name("MySecretNamespace.Message")))
22*67e74705SXin Li@property int MyProperty; // expected-error {{prefix attribute must be followed by an interface or protocol}}}}
23*67e74705SXin Li
24*67e74705SXin Li- (int) getMyProperty __attribute__((objc_runtime_name("MySecretNamespace.Message"))); // expected-error {{'objc_runtime_name' attribute only applies to interface or protocol declarations}}
25*67e74705SXin Li
26*67e74705SXin Li- (void) setMyProperty : (int) arg __attribute__((objc_runtime_name("MySecretNamespace.Message"))); // expected-error {{'objc_runtime_name' attribute only applies to interface or protocol declarations}}
27*67e74705SXin Li
28*67e74705SXin Li@end
29*67e74705SXin Li
30*67e74705SXin Li__attribute__((objc_runtime_name("MySecretNamespace.ForwardClass")))
31*67e74705SXin Li@class ForwardClass; // expected-error {{prefix attribute must be followed by an interface or protocol}}
32*67e74705SXin Li
33*67e74705SXin Li__attribute__((objc_runtime_name("MySecretNamespace.ForwardProtocol")))
34*67e74705SXin Li@protocol ForwardProtocol;
35*67e74705SXin Li
36*67e74705SXin Li__attribute__((objc_runtime_name("MySecretNamespace.Message")))
37*67e74705SXin Li@implementation Message // expected-error {{prefix attribute must be followed by an interface or protocol}}
38*67e74705SXin Li__attribute__((objc_runtime_name("MySecretNamespace.Message")))
39*67e74705SXin Li- (id) MyMethod {
40*67e74705SXin Li  return MyIVAR;
41*67e74705SXin Li}
42*67e74705SXin Li@end
43