annotate clang/test/Sema/attr-guard_nocf.c @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents c4bab56944e8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -verify -fsyntax-only %s
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -triple %ms_abi_triple -fms-extensions -verify -std=c++11 -fsyntax-only -x c++ %s
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
3 // RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -verify -fsyntax-only %s
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
4 // RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -verify -std=c++11 -fsyntax-only -x c++ %s
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
5 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -verify -fsyntax-only %s
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
6 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -verify -std=c++11 -fsyntax-only -x c++ %s
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
7
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
8 // The x86_64-w64-windows-gnu version tests mingw target, which relies on
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
9 // __declspec(...) being defined as __attribute__((...)) by compiler built-in.
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
10
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
11 #if defined(_WIN32)
150
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 // Function definition.
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
14 __declspec(guard(nocf)) void testGuardNoCF(void) { // no warning
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
15 }
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
16
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
17 // Function definition using GNU-style attribute without relying on the
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
18 // __declspec define for mingw.
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
19 __attribute__((guard(nocf))) void testGNUStyleGuardNoCF(void) { // no warning
150
anatofuz
parents:
diff changeset
20 }
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 // Can not be used on variable, parameter, or function pointer declarations.
anatofuz
parents:
diff changeset
23 int __declspec(guard(nocf)) i; // expected-warning {{'guard' attribute only applies to functions}}
anatofuz
parents:
diff changeset
24 void testGuardNoCFFuncParam(double __declspec(guard(nocf)) i) {} // expected-warning {{'guard' attribute only applies to functions}}
anatofuz
parents:
diff changeset
25 __declspec(guard(nocf)) typedef void (*FuncPtrWithGuardNoCF)(void); // expected-warning {{'guard' attribute only applies to functions}}
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 // 'guard' Attribute requries an argument.
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
28 __declspec(guard) void testGuardNoCFParams(void) { // expected-error {{'guard' attribute takes one argument}}
150
anatofuz
parents:
diff changeset
29 }
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 // 'guard' Attribute requries an identifier as argument.
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
32 __declspec(guard(1)) void testGuardNoCFParamType(void) { // expected-error {{'guard' attribute requires an identifier}}
150
anatofuz
parents:
diff changeset
33 }
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 // 'guard' Attribute only takes a single argument.
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
36 __declspec(guard(nocf, nocf)) void testGuardNoCFTooManyParams(void) { // expected-error {{use of undeclared identifier 'nocf'}}
150
anatofuz
parents:
diff changeset
37 }
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 // 'guard' Attribute argument must be a supported identifier.
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
40 __declspec(guard(cf)) void testGuardNoCFInvalidParam(void) { // expected-warning {{'guard' attribute argument not supported: 'cf'}}
150
anatofuz
parents:
diff changeset
41 }
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
42
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
43 #else
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
44
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
45 __attribute((guard(nocf))) void testGNUStyleGuardNoCF(void) {} // expected-warning {{unknown attribute 'guard' ignored}}
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
46
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
47 #endif