[RISCV] Add shrinkwrap test cases showing gaps in current impl
[llvm-project.git] / clang / test / Preprocessor / has_attribute.cpp
blob00ec57615c84b81df08739c2fc73ccd9d4323db2
1 // RUN: %clang_cc1 -triple i386-unknown-unknown -fms-compatibility -std=c++03 -E -P %s -o - | FileCheck %s --check-prefixes=CHECK,ITANIUM --implicit-check-not=:
2 // 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=:
3 // RUN: %clang_cc1 -triple i386-windows -fms-compatibility -std=c++03 -E -P %s -o - | FileCheck %s --check-prefixes=CHECK,WINDOWS --implicit-check-not=:
4 // RUN: %clang_cc1 -triple i386-windows -fms-compatibility -std=c++11 -E -P %s -o - | FileCheck %s --check-prefixes=CHECK,WINDOWS --implicit-check-not=:
6 #define CXX11(x) x: __has_cpp_attribute(x)
8 // CHECK: clang::fallthrough: 1
9 CXX11(clang::fallthrough)
11 // CHECK: selectany: 0
12 CXX11(selectany)
14 // The attribute name can be bracketed with double underscores.
15 // CHECK: clang::__fallthrough__: 1
16 CXX11(clang::__fallthrough__)
18 // The scope cannot be bracketed with double underscores unless it is
19 // for gnu or clang.
20 // CHECK: __gsl__::suppress: 0
21 CXX11(__gsl__::suppress)
23 // CHECK: _Clang::fallthrough: 1
24 CXX11(_Clang::fallthrough)
26 // CHECK: __nodiscard__: 201907L
27 CXX11(__nodiscard__)
29 // CHECK: warn_unused_result: 0
30 CXX11(warn_unused_result)
32 // CHECK: gnu::warn_unused_result: 1
33 CXX11(gnu::warn_unused_result)
35 // CHECK: clang::warn_unused_result: 1
36 CXX11(clang::warn_unused_result)
38 // CHECK: __gnu__::__const__: 1
39 CXX11(__gnu__::__const__)
41 // Test that C++11, target-specific attributes behave properly.
43 // CHECK: gnu::mips16: 0
44 CXX11(gnu::mips16)
46 // Test for standard attributes as listed in C++2a [cpp.cond] paragraph 6.
48 CXX11(assert)
49 CXX11(carries_dependency)
50 CXX11(deprecated)
51 CXX11(ensures)
52 CXX11(expects)
53 CXX11(fallthrough)
54 CXX11(likely)
55 CXX11(maybe_unused)
56 CXX11(no_unique_address)
57 CXX11(msvc::no_unique_address)
58 CXX11(nodiscard)
59 CXX11(noreturn)
60 CXX11(unlikely)
61 // FIXME(201806L) CHECK: assert: 0
62 // CHECK: carries_dependency: 200809L
63 // CHECK: deprecated: 201309L
64 // FIXME(201806L) CHECK: ensures: 0
65 // FIXME(201806L) CHECK: expects: 0
66 // CHECK: fallthrough: 201603L
67 // CHECK: likely: 201803L
68 // CHECK: maybe_unused: 201603L
69 // ITANIUM: no_unique_address: 201803L
70 // WINDOWS: no_unique_address: 0
71 // ITANIUM: msvc::no_unique_address: 0
72 // WINDOWS: msvc::no_unique_address: 201803L
73 // CHECK: nodiscard: 201907L
74 // CHECK: noreturn: 200809L
75 // CHECK: unlikely: 201803L
77 namespace PR48462 {
78 // Test that macro expansion of the builtin argument works.
79 #define C clang
80 #define F fallthrough
81 #define CF clang::fallthrough
83 #if __has_cpp_attribute(F)
84 int has_fallthrough;
85 #endif
86 // CHECK: int has_fallthrough;
88 #if __has_cpp_attribute(C::F)
89 int has_clang_falthrough_1;
90 #endif
91 // CHECK: int has_clang_falthrough_1;
93 #if __has_cpp_attribute(clang::F)
94 int has_clang_falthrough_2;
95 #endif
96 // CHECK: int has_clang_falthrough_2;
98 #if __has_cpp_attribute(C::fallthrough)
99 int has_clang_falthrough_3;
100 #endif
101 // CHECK: int has_clang_falthrough_3;
103 #if __has_cpp_attribute(CF)
104 int has_clang_falthrough_4;
105 #endif
106 // CHECK: int has_clang_falthrough_4;
108 #define FUNCLIKE1(x) clang::x
109 #if __has_cpp_attribute(FUNCLIKE1(fallthrough))
110 int funclike_1;
111 #endif
112 // CHECK: int funclike_1;
114 #define FUNCLIKE2(x) _Clang::x
115 #if __has_cpp_attribute(FUNCLIKE2(fallthrough))
116 int funclike_2;
117 #endif
118 // CHECK: int funclike_2;
121 // Test for Microsoft __declspec attributes
123 #define DECLSPEC(x) x: __has_declspec_attribute(x)
125 // CHECK: uuid: 1
126 // CHECK: __uuid__: 1
127 DECLSPEC(uuid)
128 DECLSPEC(__uuid__)
130 // CHECK: fallthrough: 0
131 DECLSPEC(fallthrough)
133 namespace PR48462 {
134 // Test that macro expansion of the builtin argument works.
135 #define U uuid
137 #if __has_declspec_attribute(U)
138 int has_uuid;
139 #endif
140 // CHECK: int has_uuid;