diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -3493,7 +3493,7 @@ def CFGuard : InheritableAttr { // Currently only the __declspec(guard(nocf)) modifier is supported. In future // we might also want to support __declspec(guard(suppress)). - let Spellings = [Declspec<"guard">]; + let Spellings = [Declspec<"guard">, GCC<"guard">]; let Subjects = SubjectList<[Function]>; let Args = [EnumArgument<"Guard", "GuardArg", ["nocf"], ["nocf"]>]; let Documentation = [CFGuardDocs]; diff --git a/clang/test/CodeGen/guard_nocf.c b/clang/test/CodeGen/guard_nocf.c --- a/clang/test/CodeGen/guard_nocf.c +++ b/clang/test/CodeGen/guard_nocf.c @@ -1,4 +1,8 @@ // RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -emit-llvm -O2 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -O2 -o - %s | FileCheck %s + +// The %itanium_abi_triple version tests mingw target, which relies on +// __declspec(...) being defined as __attribute__((...)) by compiler built-in. void target_func(void); void (*func_ptr)(void) = &target_func; diff --git a/clang/test/CodeGenCXX/guard_nocf.cpp b/clang/test/CodeGenCXX/guard_nocf.cpp --- a/clang/test/CodeGenCXX/guard_nocf.cpp +++ b/clang/test/CodeGenCXX/guard_nocf.cpp @@ -1,4 +1,8 @@ // RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -std=c++11 -emit-llvm -O2 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -emit-llvm -O2 -o - %s | FileCheck %s + +// The %itanium_abi_triple version tests mingw target, which relies on +// __declspec(...) being defined as __attribute__((...)) by compiler built-in. void target_func(); void (*func_ptr)() = &target_func; diff --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test b/clang/test/Misc/pragma-attribute-supported-attributes-list.test --- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test +++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test @@ -26,6 +26,7 @@ // CHECK-NEXT: BuiltinAlias (SubjectMatchRule_function) // CHECK-NEXT: CFAuditedTransfer (SubjectMatchRule_function) // CHECK-NEXT: CFConsumed (SubjectMatchRule_variable_is_parameter) +// CHECK-NEXT: CFGuard (SubjectMatchRule_function) // CHECK-NEXT: CFICanonicalJumpTable (SubjectMatchRule_function) // CHECK-NEXT: CFUnknownTransfer (SubjectMatchRule_function) // CHECK-NEXT: CPUDispatch (SubjectMatchRule_function) diff --git a/clang/test/Sema/attr-guard_nocf.c b/clang/test/Sema/attr-guard_nocf.c --- a/clang/test/Sema/attr-guard_nocf.c +++ b/clang/test/Sema/attr-guard_nocf.c @@ -1,5 +1,10 @@ // RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -verify -fsyntax-only %s // RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -verify -std=c++11 -fsyntax-only -x c++ %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -verify -fsyntax-only %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -verify -std=c++11 -fsyntax-only -x c++ %s + +// The %itanium_abi_triple version tests mingw target, which relies on +// __declspec(...) being defined as __attribute__((...)) by compiler built-in. // Function definition. __declspec(guard(nocf)) void testGuardNoCF(void) { // no warning diff --git a/llvm/test/CodeGen/AArch64/cfguard-checks.ll b/llvm/test/CodeGen/AArch64/cfguard-checks.ll --- a/llvm/test/CodeGen/AArch64/cfguard-checks.ll +++ b/llvm/test/CodeGen/AArch64/cfguard-checks.ll @@ -1,4 +1,5 @@ ; RUN: llc < %s -mtriple=aarch64-pc-windows-msvc | FileCheck %s +; RUN: llc < %s -mtriple=aarch64-pc-windows-gnu | FileCheck %s ; Control Flow Guard is currently only available on Windows ; Test that Control Flow Guard checks are correctly added when required. diff --git a/llvm/test/CodeGen/ARM/cfguard-checks.ll b/llvm/test/CodeGen/ARM/cfguard-checks.ll --- a/llvm/test/CodeGen/ARM/cfguard-checks.ll +++ b/llvm/test/CodeGen/ARM/cfguard-checks.ll @@ -1,4 +1,5 @@ ; RUN: llc < %s -mtriple=arm-pc-windows-msvc | FileCheck %s +; RUN: llc < %s -mtriple=arm-pc-windows-gnu | FileCheck %s ; Control Flow Guard is currently only available on Windows ; Test that Control Flow Guard checks are correctly added when required. diff --git a/llvm/test/CodeGen/X86/cfguard-checks.ll b/llvm/test/CodeGen/X86/cfguard-checks.ll --- a/llvm/test/CodeGen/X86/cfguard-checks.ll +++ b/llvm/test/CodeGen/X86/cfguard-checks.ll @@ -1,5 +1,7 @@ ; RUN: llc < %s -mtriple=i686-pc-windows-msvc | FileCheck %s -check-prefix=X32 ; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc | FileCheck %s -check-prefix=X64 +; RUN: llc < %s -mtriple=i686-pc-windows-gnu | FileCheck %s -check-prefix=X32 +; RUN: llc < %s -mtriple=x86_64-pc-windows-gnu | FileCheck %s -check-prefix=X64 ; Control Flow Guard is currently only available on Windows ; Test that Control Flow Guard checks are correctly added when required.