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=:
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=:
4 #define CXX11(x) x: __has_cpp_attribute(x)
6 // CHECK: clang::fallthrough: 201603L
7 CXX11(clang::fallthrough
)
12 // The attribute name can be bracketed with double underscores.
13 // CHECK: clang::__fallthrough__: 201603L
14 CXX11(clang::__fallthrough__
)
16 // The scope cannot be bracketed with double underscores unless it is
18 // CHECK: __gsl__::suppress: 0
19 CXX11(__gsl__::suppress
)
21 // CHECK: _Clang::fallthrough: 201603L
22 CXX11(_Clang::fallthrough
)
24 // CHECK: __nodiscard__: 201907L
27 // CHECK: __gnu__::__const__: 1
28 CXX11(__gnu__::__const__
)
30 // Test that C++11, target-specific attributes behave properly.
32 // CHECK: gnu::mips16: 0
35 // Test for standard attributes as listed in C++2a [cpp.cond] paragraph 6.
38 CXX11(carries_dependency
)
45 CXX11(no_unique_address
)
49 // FIXME(201806L) CHECK: assert: 0
50 // CHECK: carries_dependency: 200809L
51 // CHECK: deprecated: 201309L
52 // FIXME(201806L) CHECK: ensures: 0
53 // FIXME(201806L) CHECK: expects: 0
54 // CHECK: fallthrough: 201603L
55 // CHECK: likely: 201803L
56 // CHECK: maybe_unused: 201603L
57 // ITANIUM: no_unique_address: 201803L
58 // WINDOWS: no_unique_address: 0
59 // CHECK: nodiscard: 201907L
60 // CHECK: noreturn: 200809L
61 // CHECK: unlikely: 201803L
64 // Test that macro expansion of the builtin argument works.
67 #define CF clang::fallthrough
69 #if __has_cpp_attribute(F)
72 // CHECK: int has_fallthrough;
74 #if __has_cpp_attribute(C::F)
75 int has_clang_falthrough_1
;
77 // CHECK: int has_clang_falthrough_1;
79 #if __has_cpp_attribute(clang::F)
80 int has_clang_falthrough_2
;
82 // CHECK: int has_clang_falthrough_2;
84 #if __has_cpp_attribute(C::fallthrough)
85 int has_clang_falthrough_3
;
87 // CHECK: int has_clang_falthrough_3;
89 #if __has_cpp_attribute(CF)
90 int has_clang_falthrough_4
;
92 // CHECK: int has_clang_falthrough_4;
94 #define FUNCLIKE1(x) clang::x
95 #if __has_cpp_attribute(FUNCLIKE1(fallthrough))
98 // CHECK: int funclike_1;
100 #define FUNCLIKE2(x) _Clang::x
101 #if __has_cpp_attribute(FUNCLIKE2(fallthrough))
104 // CHECK: int funclike_2;
107 // Test for Microsoft __declspec attributes
109 #define DECLSPEC(x) x: __has_declspec_attribute(x)
112 // CHECK: __uuid__: 1
116 // CHECK: fallthrough: 0
117 DECLSPEC(fallthrough
)
120 // Test that macro expansion of the builtin argument works.
123 #if __has_declspec_attribute(U)
126 // CHECK: int has_uuid;