xref: /llvm-project/clang/test/SemaObjC/subclassing-restricted-attr.m (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
2// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
3
4__attribute__((objc_subclassing_restricted))
5@interface Leaf // okay
6@end
7
8__attribute__((objc_subclassing_restricted))
9@interface SubClassOfLeaf : Leaf // expected-note {{class is declared here}}
10@end
11
12
13@interface SubClass : SubClassOfLeaf // expected-error {{cannot subclass a class that was declared with the 'objc_subclassing_restricted' attribute}}
14@end
15
16__attribute__((objc_root_class))
17@interface PlainRoot
18@end
19
20__attribute__((objc_subclassing_restricted))
21@interface Sub2Class : PlainRoot // okay
22@end
23
24__attribute__((objc_subclassing_restricted))
25@interface SuperImplClass // expected-note {{class is declared here}}
26@end
27@implementation SuperImplClass
28@end
29
30__attribute__((objc_subclassing_restricted))
31@interface SubImplClass : SuperImplClass
32@end
33@implementation SubImplClass // expected-error {{cannot subclass a class that was declared with the 'objc_subclassing_restricted' attribute}}
34@end
35