Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / attr-guard_nocf.c
blobc40884f45b7b7f71a8fca09643765ab399454f3b
1 // RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -verify -fsyntax-only %s
2 // RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -verify -std=c++11 -fsyntax-only -x c++ %s
3 // RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -verify -fsyntax-only %s
4 // RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -verify -std=c++11 -fsyntax-only -x c++ %s
5 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -verify -fsyntax-only %s
6 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -verify -std=c++11 -fsyntax-only -x c++ %s
8 // The x86_64-w64-windows-gnu version tests mingw target, which relies on
9 // __declspec(...) being defined as __attribute__((...)) by compiler built-in.
11 #if defined(_WIN32)
13 // Function definition.
14 __declspec(guard(nocf)) void testGuardNoCF(void) { // no warning
17 // Function definition using GNU-style attribute without relying on the
18 // __declspec define for mingw.
19 __attribute__((guard(nocf))) void testGNUStyleGuardNoCF(void) { // no warning
22 // Can not be used on variable, parameter, or function pointer declarations.
23 int __declspec(guard(nocf)) i; // expected-warning {{'guard' attribute only applies to functions}}
24 void testGuardNoCFFuncParam(double __declspec(guard(nocf)) i) {} // expected-warning {{'guard' attribute only applies to functions}}
25 __declspec(guard(nocf)) typedef void (*FuncPtrWithGuardNoCF)(void); // expected-warning {{'guard' attribute only applies to functions}}
27 // 'guard' Attribute requries an argument.
28 __declspec(guard) void testGuardNoCFParams(void) { // expected-error {{'guard' attribute takes one argument}}
31 // 'guard' Attribute requries an identifier as argument.
32 __declspec(guard(1)) void testGuardNoCFParamType(void) { // expected-error {{'guard' attribute requires an identifier}}
35 // 'guard' Attribute only takes a single argument.
36 __declspec(guard(nocf, nocf)) void testGuardNoCFTooManyParams(void) { // expected-error {{use of undeclared identifier 'nocf'}}
39 // 'guard' Attribute argument must be a supported identifier.
40 __declspec(guard(cf)) void testGuardNoCFInvalidParam(void) { // expected-warning {{'guard' attribute argument not supported: 'cf'}}
43 #else
45 __attribute((guard(nocf))) void testGNUStyleGuardNoCF(void) {} // expected-warning {{unknown attribute 'guard' ignored}}
47 #endif