|
| 1 | +// RUN: %clang_cc1 -fsyntax-only -fsanitize=kcfi -verify %s |
| 2 | + |
| 3 | +#define __cfi_salt(S) __attribute__((cfi_salt(S))) |
| 4 | + |
| 5 | +int foo(int a, int b) __cfi_salt("pepper"); // ok |
| 6 | +int foo(int a, int b) __cfi_salt("pepper"); // ok |
| 7 | + |
| 8 | +typedef int (*bar_t)(void) __cfi_salt("pepper"); // ok |
| 9 | +typedef int (*bar_t)(void) __cfi_salt("pepper"); // ok |
| 10 | + |
| 11 | +#if 0 |
| 12 | +// FIXME: These should fail. |
| 13 | +int b(void) __cfi_salt("salt 'n") __cfi_salt("pepper"); |
| 14 | +bar_t bar_fn __cfi_salt("salt 'n"); |
| 15 | +#endif |
| 16 | + |
| 17 | +int baz __cfi_salt("salt"); |
| 18 | + // expected-warning@-1{{'cfi_salt' only applies to function types}} |
| 19 | + |
| 20 | +int baz_fn(int a, int b) __cfi_salt("salt 'n"); |
| 21 | + // expected-note@-1{{previous declaration is here}} |
| 22 | +int baz_fn(int a, int b) __cfi_salt("pepper"); |
| 23 | + // expected-error@-1{{conflicting types for 'baz_fn'}} |
| 24 | + |
| 25 | +int mux_fn(int a, int b) __cfi_salt("salt 'n"); |
| 26 | + // expected-note@-1{{previous declaration is here}} |
| 27 | +int mux_fn(int a, int b) __cfi_salt("pepper") { |
| 28 | + // expected-error@-1{{conflicting types for 'mux_fn'}} |
| 29 | + return a * b; |
| 30 | +} |
| 31 | + |
| 32 | +typedef int qux_t __cfi_salt("salt"); |
| 33 | + // expected-warning@-1{{'cfi_salt' only applies to function types}} |
| 34 | + |
| 35 | +typedef int (*quux_t)(void) __cfi_salt("salt 'n"); |
| 36 | + // expected-note@-1{{previous definition is here}} |
| 37 | +typedef int (*quux_t)(void) __cfi_salt("pepper"); |
| 38 | + // expected-error@-1{{typedef redefinition with different type}} |
0 commit comments