1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 #define PLACE_IN_TCB(NAME) [[clang::enforce_tcb(NAME)]]
4 #define PLACE_IN_TCB_LEAF(NAME) [[clang::enforce_tcb_leaf(NAME)]]
6 PLACE_IN_TCB("foo") void in_tcb_foo();
9 // Test behavior on classes and methods.
15 // TODO: Figure out if we want to support methods at all.
16 // Does it even make sense to isolate individual methods into a TCB?
17 // Maybe a per-class attribute would make more sense?
18 bar(); // expected-warning{{calling 'bar' is a violation of trusted computing base 'foo'}}
22 // Test behavior on templates.
23 template <typename Ty
>
25 void foo_never_instantiated() {
26 not_in_tcb(); // expected-warning{{calling 'not_in_tcb' is a violation of trusted computing base 'foo'}}
27 in_tcb_foo(); // no-warning
30 template <typename Ty
>
32 void foo_specialized();
35 void foo_specialized
<int>() {
36 not_in_tcb(); // expected-warning{{calling 'not_in_tcb' is a violation of trusted computing base 'foo'}}
37 in_tcb_foo(); // no-warning
41 void call_template_good() {
42 foo_specialized
<int>(); // no-warning
45 void call_template_bad() {
46 foo_specialized
<int>(); // expected-warning{{calling 'foo_specialized<int>' is a violation of trusted computing base 'bar'}}
50 void foo_specialization_in_tcb();
54 void foo_specialization_in_tcb
<int>() {
55 not_in_tcb(); //expected-warning{{calling 'not_in_tcb' is a violation of trusted computing base 'foo'}}
56 in_tcb_foo(); // no-warning
60 void foo_specialization_in_tcb
<double>() {
61 not_in_tcb(); // no-warning
62 in_tcb_foo(); // no-warning
66 void call_specialization_in_tcb() {
67 foo_specialization_in_tcb
<int>(); // no-warning
68 foo_specialization_in_tcb
<long>(); // expected-warning{{calling 'foo_specialization_in_tcb<long>' is a violation of trusted computing base 'foo'}}
69 foo_specialization_in_tcb
<double>(); // expected-warning{{'foo_specialization_in_tcb<double>' is a violation of trusted computing base 'foo'}}