xref: /llvm-project/clang/test/Sema/attr-enforce-tcb.m (revision c8048c7c42ffd1731149b0abe15b9081dd27c789)
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3#define PLACE_IN_TCB(NAME) __attribute__((enforce_tcb(NAME)))
4#define PLACE_IN_TCB_LEAF(NAME) __attribute__((enforce_tcb_leaf(NAME)))
5
6__attribute__((objc_root_class))
7@interface AClass
8@property(readonly) id propertyNotInAnyTCB;
9@end
10
11@implementation AClass
12- (void)inTCBFoo PLACE_IN_TCB("foo") {
13  [self notInAnyTCB]; // expected-warning{{calling 'notInAnyTCB' is a violation of trusted computing base 'foo'}}
14}
15- (void)inTCBFooAsLeaf PLACE_IN_TCB_LEAF("foo") {
16  [self notInAnyTCB]; // no-warning
17}
18- (void)notInAnyTCB {
19}
20+ (void)classMethodNotInAnyTCB {
21}
22+ (void)classMethodInTCBFoo PLACE_IN_TCB("foo") {
23  [self inTCBFoo];       // no-warning
24  [self inTCBFooAsLeaf]; // no-warning
25  [self notInAnyTCB];    // expected-warning{{calling 'notInAnyTCB' is a violation of trusted computing base 'foo'}}
26}
27@end
28
29PLACE_IN_TCB("foo")
30void call_objc_method(AClass *object) {
31  [object inTCBFoo];                // no-warning
32  [object inTCBFooAsLeaf];          // no-warning
33  [object notInAnyTCB];             // expected-warning{{calling 'notInAnyTCB' is a violation of trusted computing base 'foo'}}
34  [AClass classMethodNotInAnyTCB];  // expected-warning{{calling 'classMethodNotInAnyTCB' is a violation of trusted computing base 'foo'}}
35  [AClass classMethodInTCBFoo];     // no-warning
36  (void)object.propertyNotInAnyTCB; // expected-warning{{calling 'propertyNotInAnyTCB' is a violation of trusted computing base 'foo'}}
37}
38