1 // RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -emit-llvm -O2 -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -emit-llvm -O2 -o - %s | FileCheck %s
4 // The x86_64-w64-windows-gnu version tests mingw target, which relies on
5 // __declspec(...) being defined as __attribute__((...)) by compiler built-in.
7 void target_func(void);
8 void (*func_ptr
)(void) = &target_func
;
10 // The "guard_nocf" attribute must be added.
11 __declspec(guard(nocf
)) void nocf0(void) {
15 // CHECK: call{{.*}}[[NOCF:#[0-9]+]]
17 // Explicitly test using the GNU-style attribute without relying on the
18 // __declspec define for mingw.
19 // The "guard_nocf" attribute must be added.
20 __attribute__((guard(nocf
))) void nocf0_gnu_style(void) {
23 // CHECK-LABEL: nocf0_gnu_style
24 // CHECK: call{{.*}}[[NOCF:#[0-9]+]]
26 // The "guard_nocf" attribute must *not* be added.
31 // CHECK: call{{.*}}[[CF:#[0-9]+]]
33 // If the modifier is present on either the function declaration or definition,
34 // the "guard_nocf" attribute must be added.
35 __declspec(guard(nocf
)) void nocf1(void);
40 // CHECK: call{{.*}}[[NOCF:#[0-9]+]]
43 __declspec(guard(nocf
)) void nocf2(void) {
47 // CHECK: call{{.*}}[[NOCF:#[0-9]+]]
49 // When inlining a function, the "guard_nocf" attribute on indirect calls must
55 // CHECK: call{{.*}}[[NOCF:#[0-9]+]]
57 // When inlining into a function marked as __declspec(guard(nocf)), the
58 // "guard_nocf" attribute must *not* be added to the inlined calls.
59 __declspec(guard(nocf
)) void cf1(void) {
63 // CHECK: call{{.*}}[[CF:#[0-9]+]]
65 // CHECK: attributes [[NOCF]] = { {{.*}}"guard_nocf"{{.*}} }
66 // CHECK-NOT: attributes [[CF]] = { {{.*}}"guard_nocf"{{.*}} }