1// RUN: %clang_cc1 -fsyntax-only -verify %s 2 3int foo(); 4 5__attribute__((objc_root_class)) 6@interface AClass 7- (void)bothTCBAndTCBLeafOnSeparateRedeclarations __attribute__((enforce_tcb("x"))); // expected-note{{conflicting attribute is here}} 8 9- (void)bothTCBAndTCBLeafOnSeparateRedeclarationsOppositeOrder __attribute__((enforce_tcb_leaf("x"))); // expected-note{{conflicting attribute is here}} 10 11- (void)bothTCBAndTCBLeafButDifferentIdentifiersOnSeparateRedeclarations __attribute__((enforce_tcb("x"))); 12 13- (void)bothTCBAndTCBLeafButDifferentIdentifiersOnSeparateRedeclarationsOppositeOrder __attribute__((enforce_tcb_leaf("x"))); 14 15- (void)onInterfaceOnly __attribute__((enforce_tcb("test"))); 16@end 17 18@interface AClass (NoImplementation) 19- (void)noArguments __attribute__((enforce_tcb)); // expected-error{{'enforce_tcb' attribute takes one argument}} 20 21- (void)tooManyArguments __attribute__((enforce_tcb("test", 12))); // expected-error{{'enforce_tcb' attribute takes one argument}} 22 23- (void)wrongArgumentType __attribute__((enforce_tcb(12))); // expected-error{{expected string literal as argument of 'enforce_tcb' attribute}} 24 25- (void)noArgumentsLeaf __attribute__((enforce_tcb_leaf)); // expected-error{{'enforce_tcb_leaf' attribute takes one argument}} 26 27- (void)tooManyArgumentsLeaf __attribute__((enforce_tcb_leaf("test", 12))); // expected-error{{'enforce_tcb_leaf' attribute takes one argument}} 28 29- (void)wrongArgumentTypeLeaf __attribute__((enforce_tcb_leaf(12))); // expected-error{{expected string literal as argument of 'enforce_tcb_leaf' attribute}} 30@end 31 32@implementation AClass 33- (void)onInterfaceOnly { 34 foo(); // expected-warning{{calling 'foo' is a violation of trusted computing base 'test'}} 35} 36 37- (void)bothTCBAndTCBLeaf 38 __attribute__((enforce_tcb("x"))) 39 __attribute__((enforce_tcb_leaf("x"))) // expected-error{{attributes 'enforce_tcb_leaf("x")' and 'enforce_tcb("x")' are mutually exclusive}} 40{ 41 foo(); // no-warning 42} 43 44- (void)bothTCBAndTCBLeafOnSeparateRedeclarations 45 __attribute__((enforce_tcb_leaf("x"))) // expected-error{{attributes 'enforce_tcb_leaf("x")' and 'enforce_tcb("x")' are mutually exclusive}} 46{ 47 // Error recovery: no need to emit a warning when we didn't 48 // figure out our attributes to begin with. 49 foo(); // no-warning 50} 51 52- (void)bothTCBAndTCBLeafOppositeOrder 53 __attribute__((enforce_tcb_leaf("x"))) 54 __attribute__((enforce_tcb("x"))) // expected-error{{attributes 'enforce_tcb("x")' and 'enforce_tcb_leaf("x")' are mutually exclusive}} 55{ 56 foo(); // no-warning 57} 58 59- (void)bothTCBAndTCBLeafOnSeparateRedeclarationsOppositeOrder 60 __attribute__((enforce_tcb("x"))) // expected-error{{attributes 'enforce_tcb("x")' and 'enforce_tcb_leaf("x")' are mutually exclusive}} 61{ 62 foo(); // no-warning 63} 64 65- (void)bothTCBAndTCBLeafButDifferentIdentifiers 66 __attribute__((enforce_tcb("x"))) 67 __attribute__((enforce_tcb_leaf("y"))) // no-error 68{ 69 foo(); // expected-warning{{calling 'foo' is a violation of trusted computing base 'x'}} 70} 71 72- (void)bothTCBAndTCBLeafButDifferentIdentifiersOppositeOrder 73 __attribute__((enforce_tcb_leaf("x"))) 74 __attribute__((enforce_tcb("y"))) // no-error 75{ 76 foo(); // expected-warning{{calling 'foo' is a violation of trusted computing base 'y'}} 77} 78 79- (void)bothTCBAndTCBLeafButDifferentIdentifiersOnSeparateRedeclarations 80 __attribute__((enforce_tcb_leaf("y"))) // no-error 81{ 82 foo(); // expected-warning{{calling 'foo' is a violation of trusted computing base 'x'}} 83} 84 85- (void)bothTCBAndTCBLeafButDifferentIdentifiersOnSeparateRedeclarationsOppositeOrder 86 __attribute__((enforce_tcb("y"))) { 87 foo(); // expected-warning{{calling 'foo' is a violation of trusted computing base 'y'}} 88} 89 90- (void)errorRecoveryOverIndividualTCBs 91 __attribute__((enforce_tcb("y"))) 92 __attribute__((enforce_tcb("x"))) 93 __attribute__((enforce_tcb_leaf("x"))) // expected-error{{attributes 'enforce_tcb_leaf("x")' and 'enforce_tcb("x")' are mutually exclusive}} 94{ 95 // FIXME: Ideally this should warn. The conflict between attributes 96 // for TCB "x" shouldn't affect the warning about TCB "y". 97 foo(); // no-warning 98} 99 100@end 101