48 lines · c
1// RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -verify -fsyntax-only %s2// RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -verify -std=c++11 -fsyntax-only -x c++ %s3// RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -verify -fsyntax-only %s4// RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -verify -std=c++11 -fsyntax-only -x c++ %s5// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -verify -fsyntax-only %s6// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -verify -std=c++11 -fsyntax-only -x c++ %s7 8// The x86_64-w64-windows-gnu version tests mingw target, which relies on9// __declspec(...) being defined as __attribute__((...)) by compiler built-in.10 11#if defined(_WIN32)12 13// Function definition.14__declspec(guard(nocf)) void testGuardNoCF(void) { // no warning15}16 17// Function definition using GNU-style attribute without relying on the18// __declspec define for mingw.19__attribute__((guard(nocf))) void testGNUStyleGuardNoCF(void) { // no warning20}21 22// Can not be used on variable, parameter, or function pointer declarations.23int __declspec(guard(nocf)) i; // expected-warning {{'guard' attribute only applies to functions}}24void 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}}26 27// 'guard' Attribute requries an argument.28__declspec(guard) void testGuardNoCFParams(void) { // expected-error {{'guard' attribute takes one argument}}29}30 31// 'guard' Attribute requries an identifier as argument.32__declspec(guard(1)) void testGuardNoCFParamType(void) { // expected-error {{'guard' attribute requires an identifier}}33}34 35// 'guard' Attribute only takes a single argument.36__declspec(guard(nocf, nocf)) void testGuardNoCFTooManyParams(void) { // expected-error {{use of undeclared identifier 'nocf'}}37}38 39// 'guard' Attribute argument must be a supported identifier.40__declspec(guard(cf)) void testGuardNoCFInvalidParam(void) { // expected-warning {{'guard' attribute argument not supported: 'cf'}}41}42 43#else44 45__attribute((guard(nocf))) void testGNUStyleGuardNoCF(void) {} // expected-warning {{unknown attribute 'guard' ignored}}46 47#endif48