================ @@ -0,0 +1,67 @@ +// RUN: %clang_cc1 -fsyntax-only -fsanitize=kcfi -verify %s + +#define __cfi_salt(S) __attribute__((cfi_salt(S))) + +int bad1() __cfi_salt(); + // expected-error@-1{{'cfi_salt' attribute takes one argument}} +int bad2() __cfi_salt(42); + // expected-error@-1{{expected string literal as argument of 'cfi_salt' attribute}} + +int foo(int a, int b) __cfi_salt("pepper"); // ok +int foo(int a, int b) __cfi_salt("pepper"); // ok + +typedef int (*bar_t)(void) __cfi_salt("pepper"); // ok +typedef int (*bar_t)(void) __cfi_salt("pepper"); // ok + +// FIXME: Should we allow this? +// int b(void) __cfi_salt("salt 'n") __cfi_salt("pepper"); +// bar_t bar_fn __cfi_salt("salt 'n"); + +int baz __cfi_salt("salt"); + // expected-warning@-1{{'cfi_salt' only applies to function types}} + +int baz_fn(int a, int b) __cfi_salt("salt 'n"); + // expected-note@-1{{previous declaration is here}} ---------------- erichkeane wrote:
I have a VERY strong preference for putting the 'note' immediately after the 'error' textually and doing whatever it takes to get the '@' to work right (I typically suggest our bookmark feature, but with these that is obviously not necessary). For example, while reading this test, it took me an unfortunate amount of time to figure out which error this went with. https://github.com/llvm/llvm-project/pull/141846 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits