================
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -fsanitize=kcfi -verify %s
+
+#define __cfi_salt(S) __attribute__((cfi_salt(S)))
+
+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
+
+#if 0
+// FIXME: These should fail.
+int b(void) __cfi_salt("salt 'n") __cfi_salt("pepper");
+bar_t bar_fn __cfi_salt("salt 'n");
+#endif
+
----------------
bwendling wrote:

> ```
> void func(int a) __cfi_salt("pepper");
> void func(int a) { } // Okay, inherits the attribute from the declaration.
> ```

This isn't allowed, because function types don't appear to work that way.

> ```
> void blah() __attribute__((cfi_salt)); // Error, missing argument to the 
> attribute
> void blarg() __attribute__((cfi_salt(5))); // Error, argument to the 
> attribute is not a string
> ```

Okay.

> ```
> void okay() [[clang::cfi_salt("test")]]; // Uses the [[]] syntax which 
> appertains to the function type
> void (*fp)() = okay; // Is this okay to drop the type attribute? Or is this 
> an error?
> ```

No, because it would lose the attribute.


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

Reply via email to