annotate clang/test/Preprocessor/has_attribute.cpp @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 79ff65ed7e25
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple i386-unknown-unknown -fms-compatibility -std=c++11 -E -P %s -o - | FileCheck %s --check-prefixes=CHECK,ITANIUM --implicit-check-not=:
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -triple i386-windows -fms-compatibility -std=c++11 -E -P %s -o - | FileCheck %s --check-prefixes=CHECK,WINDOWS --implicit-check-not=:
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 #define CXX11(x) x: __has_cpp_attribute(x)
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 // CHECK: clang::fallthrough: 201603L
anatofuz
parents:
diff changeset
7 CXX11(clang::fallthrough)
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 // CHECK: selectany: 0
anatofuz
parents:
diff changeset
10 CXX11(selectany)
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 // The attribute name can be bracketed with double underscores.
anatofuz
parents:
diff changeset
13 // CHECK: clang::__fallthrough__: 201603L
anatofuz
parents:
diff changeset
14 CXX11(clang::__fallthrough__)
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 // The scope cannot be bracketed with double underscores unless it is
anatofuz
parents:
diff changeset
17 // for gnu or clang.
anatofuz
parents:
diff changeset
18 // CHECK: __gsl__::suppress: 0
anatofuz
parents:
diff changeset
19 CXX11(__gsl__::suppress)
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 // CHECK: _Clang::fallthrough: 201603L
anatofuz
parents:
diff changeset
22 CXX11(_Clang::fallthrough)
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 // CHECK: __nodiscard__: 201907L
anatofuz
parents:
diff changeset
25 CXX11(__nodiscard__)
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 // CHECK: __gnu__::__const__: 1
anatofuz
parents:
diff changeset
28 CXX11(__gnu__::__const__)
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 // Test that C++11, target-specific attributes behave properly.
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 // CHECK: gnu::mips16: 0
anatofuz
parents:
diff changeset
33 CXX11(gnu::mips16)
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 // Test for standard attributes as listed in C++2a [cpp.cond] paragraph 6.
anatofuz
parents:
diff changeset
36
anatofuz
parents:
diff changeset
37 CXX11(assert)
anatofuz
parents:
diff changeset
38 CXX11(carries_dependency)
anatofuz
parents:
diff changeset
39 CXX11(deprecated)
anatofuz
parents:
diff changeset
40 CXX11(ensures)
anatofuz
parents:
diff changeset
41 CXX11(expects)
anatofuz
parents:
diff changeset
42 CXX11(fallthrough)
anatofuz
parents:
diff changeset
43 CXX11(likely)
anatofuz
parents:
diff changeset
44 CXX11(maybe_unused)
anatofuz
parents:
diff changeset
45 CXX11(no_unique_address)
anatofuz
parents:
diff changeset
46 CXX11(nodiscard)
anatofuz
parents:
diff changeset
47 CXX11(noreturn)
anatofuz
parents:
diff changeset
48 CXX11(unlikely)
anatofuz
parents:
diff changeset
49 // FIXME(201806L) CHECK: assert: 0
anatofuz
parents:
diff changeset
50 // CHECK: carries_dependency: 200809L
anatofuz
parents:
diff changeset
51 // CHECK: deprecated: 201309L
anatofuz
parents:
diff changeset
52 // FIXME(201806L) CHECK: ensures: 0
anatofuz
parents:
diff changeset
53 // FIXME(201806L) CHECK: expects: 0
anatofuz
parents:
diff changeset
54 // CHECK: fallthrough: 201603L
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
55 // CHECK: likely: 201803L
150
anatofuz
parents:
diff changeset
56 // CHECK: maybe_unused: 201603L
anatofuz
parents:
diff changeset
57 // ITANIUM: no_unique_address: 201803L
anatofuz
parents:
diff changeset
58 // WINDOWS: no_unique_address: 0
anatofuz
parents:
diff changeset
59 // CHECK: nodiscard: 201907L
anatofuz
parents:
diff changeset
60 // CHECK: noreturn: 200809L
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
61 // CHECK: unlikely: 201803L
150
anatofuz
parents:
diff changeset
62
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
63 namespace PR48462 {
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
64 // Test that macro expansion of the builtin argument works.
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
65 #define C clang
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
66 #define F fallthrough
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
67 #define CF clang::fallthrough
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
68
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
69 #if __has_cpp_attribute(F)
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
70 int has_fallthrough;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
71 #endif
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
72 // CHECK: int has_fallthrough;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
73
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
74 #if __has_cpp_attribute(C::F)
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
75 int has_clang_falthrough_1;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
76 #endif
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
77 // CHECK: int has_clang_falthrough_1;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
78
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
79 #if __has_cpp_attribute(clang::F)
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
80 int has_clang_falthrough_2;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
81 #endif
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
82 // CHECK: int has_clang_falthrough_2;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
83
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
84 #if __has_cpp_attribute(C::fallthrough)
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
85 int has_clang_falthrough_3;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
86 #endif
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
87 // CHECK: int has_clang_falthrough_3;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
88
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
89 #if __has_cpp_attribute(CF)
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
90 int has_clang_falthrough_4;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
91 #endif
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
92 // CHECK: int has_clang_falthrough_4;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
93
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
94 #define FUNCLIKE1(x) clang::x
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
95 #if __has_cpp_attribute(FUNCLIKE1(fallthrough))
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
96 int funclike_1;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
97 #endif
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
98 // CHECK: int funclike_1;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
99
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
100 #define FUNCLIKE2(x) _Clang::x
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
101 #if __has_cpp_attribute(FUNCLIKE2(fallthrough))
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
102 int funclike_2;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
103 #endif
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
104 // CHECK: int funclike_2;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
105 }
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
106
150
anatofuz
parents:
diff changeset
107 // Test for Microsoft __declspec attributes
anatofuz
parents:
diff changeset
108
anatofuz
parents:
diff changeset
109 #define DECLSPEC(x) x: __has_declspec_attribute(x)
anatofuz
parents:
diff changeset
110
anatofuz
parents:
diff changeset
111 // CHECK: uuid: 1
anatofuz
parents:
diff changeset
112 // CHECK: __uuid__: 1
anatofuz
parents:
diff changeset
113 DECLSPEC(uuid)
anatofuz
parents:
diff changeset
114 DECLSPEC(__uuid__)
anatofuz
parents:
diff changeset
115
anatofuz
parents:
diff changeset
116 // CHECK: fallthrough: 0
anatofuz
parents:
diff changeset
117 DECLSPEC(fallthrough)
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
118
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
119 namespace PR48462 {
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
120 // Test that macro expansion of the builtin argument works.
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
121 #define U uuid
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
122
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
123 #if __has_declspec_attribute(U)
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
124 int has_uuid;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
125 #endif
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
126 // CHECK: int has_uuid;
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
127 }