brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.0 KiB · 732636e Raw
81 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3[[clang::enforce_tcb("oops")]] int wrong_subject_type; // expected-warning{{'clang::enforce_tcb' attribute only applies to functions}}4 5void no_arguments() __attribute__((enforce_tcb)); // expected-error{{'enforce_tcb' attribute takes one argument}}6 7void too_many_arguments() __attribute__((enforce_tcb("test", 12))); // expected-error{{'enforce_tcb' attribute takes one argument}}8 9void wrong_argument_type() __attribute__((enforce_tcb(12))); // expected-error{{expected string literal as argument of 'enforce_tcb' attribute}}10 11[[clang::enforce_tcb_leaf("oops")]] int wrong_subject_type_leaf; // expected-warning{{'clang::enforce_tcb_leaf' attribute only applies to functions}}12 13void no_arguments_leaf() __attribute__((enforce_tcb_leaf)); // expected-error{{'enforce_tcb_leaf' attribute takes one argument}}14 15void too_many_arguments_leaf() __attribute__((enforce_tcb_leaf("test", 12))); // expected-error{{'enforce_tcb_leaf' attribute takes one argument}}16void wrong_argument_type_leaf() __attribute__((enforce_tcb_leaf(12))); // expected-error{{expected string literal as argument of 'enforce_tcb_leaf' attribute}}17 18void foo();19 20__attribute__((enforce_tcb("x")))21__attribute__((enforce_tcb_leaf("x"))) // expected-error{{attributes 'enforce_tcb_leaf("x")' and 'enforce_tcb("x")' are mutually exclusive}}22void both_tcb_and_tcb_leaf() {23  foo(); // no-warning24}25 26__attribute__((enforce_tcb_leaf("x"))) // expected-note{{conflicting attribute is here}}27void both_tcb_and_tcb_leaf_on_separate_redeclarations();28__attribute__((enforce_tcb("x"))) // expected-error{{attributes 'enforce_tcb("x")' and 'enforce_tcb_leaf("x")' are mutually exclusive}}29void both_tcb_and_tcb_leaf_on_separate_redeclarations() {30  // Error recovery: no need to emit a warning when we didn't31  // figure out our attributes to begin with.32  foo(); // no-warning33}34 35__attribute__((enforce_tcb_leaf("x")))36__attribute__((enforce_tcb("x"))) // expected-error{{attributes 'enforce_tcb("x")' and 'enforce_tcb_leaf("x")' are mutually exclusive}}37void both_tcb_and_tcb_leaf_opposite_order() {38  foo(); // no-warning39}40 41__attribute__((enforce_tcb("x"))) // expected-note{{conflicting attribute is here}}42void both_tcb_and_tcb_leaf_on_separate_redeclarations_opposite_order();43__attribute__((enforce_tcb_leaf("x"))) // expected-error{{attributes 'enforce_tcb_leaf("x")' and 'enforce_tcb("x")' are mutually exclusive}}44void both_tcb_and_tcb_leaf_on_separate_redeclarations_opposite_order() {45  foo(); // no-warning46}47 48__attribute__((enforce_tcb("x")))49__attribute__((enforce_tcb_leaf("y"))) // no-error50void both_tcb_and_tcb_leaf_but_different_identifiers() {51  foo(); // expected-warning{{calling 'foo' is a violation of trusted computing base 'x'}}52}53__attribute__((enforce_tcb_leaf("x")))54__attribute__((enforce_tcb("y"))) // no-error55void both_tcb_and_tcb_leaf_but_different_identifiers_opposite_order() {56  foo(); // expected-warning{{calling 'foo' is a violation of trusted computing base 'y'}}57}58 59__attribute__((enforce_tcb("x")))60void both_tcb_and_tcb_leaf_but_different_identifiers_on_separate_redeclarations();61__attribute__((enforce_tcb_leaf("y"))) // no-error62void both_tcb_and_tcb_leaf_but_different_identifiers_on_separate_redeclarations() {63  foo(); // expected-warning{{calling 'foo' is a violation of trusted computing base 'x'}}64}65 66__attribute__((enforce_tcb_leaf("x")))67void both_tcb_and_tcb_leaf_but_different_identifiers_on_separate_redeclarations_opposite_order();68__attribute__((enforce_tcb("y")))69void both_tcb_and_tcb_leaf_but_different_identifiers_on_separate_redeclarations_opposite_order() {70  foo(); // expected-warning{{calling 'foo' is a violation of trusted computing base 'y'}}71}72 73__attribute__((enforce_tcb("y")))74__attribute__((enforce_tcb("x")))75__attribute__((enforce_tcb_leaf("x"))) // expected-error{{attributes 'enforce_tcb_leaf("x")' and 'enforce_tcb("x")' are mutually exclusive}}76void error_recovery_over_individual_tcbs() {77  // FIXME: Ideally this should warn. The conflict between attributes78  // for TCB "x" shouldn't affect the warning about TCB "y".79  foo(); // no-warning80}81