mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 09:16:05 +00:00

in gcc by https://gcc.gnu.org/ml/gcc-cvs/2018-04/msg00534.html. The -mibt feature flag is being removed, and the -fcf-protection option now also defines a CET macro and causes errors when used on non-X86 targets, while X86 targets no longer check for -mibt and -mshstk to determine if -fcf-protection is supported. -mshstk is now used only to determine availability of shadow stack intrinsics. Comes with an LLVM patch (D46882). Patch by mike.dvoretsky Differential Revision: https://reviews.llvm.org/D46881 llvm-svn: 332704
24 lines
1.3 KiB
C++
24 lines
1.3 KiB
C++
// RUN: %clang_cc1 -triple=i386-unknown-unknown -verify -fcf-protection=branch -std=c++11 -fsyntax-only %s
|
|
|
|
// Function pointer definition.
|
|
[[gnu::nocf_check]] typedef void (*FuncPointerWithNoCfCheck)(void); // no-warning
|
|
typedef void (*FuncPointer)(void);
|
|
|
|
// Dont allow function declaration and definition mismatch.
|
|
[[gnu::nocf_check]] void testNoCfCheck(); // expected-note {{previous declaration is here}}
|
|
void testNoCfCheck(){}; // expected-error {{conflicting types for 'testNoCfCheck'}}
|
|
|
|
// No variable or parameter declaration
|
|
int [[gnu::nocf_check]] i; // expected-error {{'nocf_check' attribute cannot be applied to types}}
|
|
void testNoCfCheckImpl(double i [[gnu::nocf_check]]) {} // expected-warning {{'nocf_check' attribute only applies to functions and function pointers}}
|
|
|
|
// Allow attributed function pointers as well as casting between attributed
|
|
// and non-attributed function pointers.
|
|
void testNoCfCheckMismatch(FuncPointer f) {
|
|
FuncPointerWithNoCfCheck fNoCfCheck = f; // expected-error {{cannot initialize a variable of type}}
|
|
(*fNoCfCheck)(); // no-warning
|
|
}
|
|
|
|
// 'nocf_check' Attribute has no parameters.
|
|
[[gnu::nocf_check(1)]] int testNoCfCheckParams(); // expected-error {{'nocf_check' attribute takes no arguments}}
|