xref: /minix3/external/bsd/llvm/dist/clang/test/Preprocessor/has_attribute.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple i386-unknown-unknown -fms-compatibility -std=c++11 -E %s -o - | FileCheck %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc // CHECK: has_cxx11_carries_dep
4*0a6a1f1dSLionel Sambuc #if __has_cpp_attribute(carries_dependency)
5*0a6a1f1dSLionel Sambuc   int has_cxx11_carries_dep();
6*0a6a1f1dSLionel Sambuc #endif
7*0a6a1f1dSLionel Sambuc 
8*0a6a1f1dSLionel Sambuc // CHECK: has_clang_fallthrough_1
9*0a6a1f1dSLionel Sambuc #if __has_cpp_attribute(clang::fallthrough)
10*0a6a1f1dSLionel Sambuc   int has_clang_fallthrough_1();
11*0a6a1f1dSLionel Sambuc #endif
12*0a6a1f1dSLionel Sambuc 
13*0a6a1f1dSLionel Sambuc // CHECK: does_not_have_selectany
14*0a6a1f1dSLionel Sambuc #if !__has_cpp_attribute(selectany)
15*0a6a1f1dSLionel Sambuc   int does_not_have_selectany();
16*0a6a1f1dSLionel Sambuc #endif
17*0a6a1f1dSLionel Sambuc 
18*0a6a1f1dSLionel Sambuc // The attribute name can be bracketed with double underscores.
19*0a6a1f1dSLionel Sambuc // CHECK: has_clang_fallthrough_2
20*0a6a1f1dSLionel Sambuc #if __has_cpp_attribute(clang::__fallthrough__)
21*0a6a1f1dSLionel Sambuc   int has_clang_fallthrough_2();
22*0a6a1f1dSLionel Sambuc #endif
23*0a6a1f1dSLionel Sambuc 
24*0a6a1f1dSLionel Sambuc // The scope cannot be bracketed with double underscores.
25*0a6a1f1dSLionel Sambuc // CHECK: does_not_have___clang___fallthrough
26*0a6a1f1dSLionel Sambuc #if !__has_cpp_attribute(__clang__::fallthrough)
27*0a6a1f1dSLionel Sambuc   int does_not_have___clang___fallthrough();
28*0a6a1f1dSLionel Sambuc #endif
29*0a6a1f1dSLionel Sambuc 
30*0a6a1f1dSLionel Sambuc // Test that C++11, target-specific attributes behave properly.
31*0a6a1f1dSLionel Sambuc 
32*0a6a1f1dSLionel Sambuc // CHECK: does_not_have_mips16
33*0a6a1f1dSLionel Sambuc #if !__has_cpp_attribute(gnu::mips16)
34*0a6a1f1dSLionel Sambuc   int does_not_have_mips16();
35*0a6a1f1dSLionel Sambuc #endif
36*0a6a1f1dSLionel Sambuc 
37*0a6a1f1dSLionel Sambuc // Test that the version numbers of attributes listed in SD-6 are supported
38*0a6a1f1dSLionel Sambuc // correctly.
39*0a6a1f1dSLionel Sambuc 
40*0a6a1f1dSLionel Sambuc // CHECK: has_cxx11_carries_dep_vers
41*0a6a1f1dSLionel Sambuc #if __has_cpp_attribute(carries_dependency) == 200809
42*0a6a1f1dSLionel Sambuc   int has_cxx11_carries_dep_vers();
43*0a6a1f1dSLionel Sambuc #endif
44*0a6a1f1dSLionel Sambuc 
45*0a6a1f1dSLionel Sambuc // CHECK: has_cxx11_noreturn_vers
46*0a6a1f1dSLionel Sambuc #if __has_cpp_attribute(noreturn) == 200809
47*0a6a1f1dSLionel Sambuc   int has_cxx11_noreturn_vers();
48*0a6a1f1dSLionel Sambuc #endif
49*0a6a1f1dSLionel Sambuc 
50*0a6a1f1dSLionel Sambuc // CHECK: has_cxx14_deprecated_vers
51*0a6a1f1dSLionel Sambuc #if __has_cpp_attribute(deprecated) == 201309
52*0a6a1f1dSLionel Sambuc   int has_cxx14_deprecated_vers();
53*0a6a1f1dSLionel Sambuc #endif
54*0a6a1f1dSLionel Sambuc 
55*0a6a1f1dSLionel Sambuc // CHECK: has_declspec_uuid
56*0a6a1f1dSLionel Sambuc #if __has_declspec_attribute(uuid)
57*0a6a1f1dSLionel Sambuc   int has_declspec_uuid();
58*0a6a1f1dSLionel Sambuc #endif
59*0a6a1f1dSLionel Sambuc 
60*0a6a1f1dSLionel Sambuc // CHECK: has_declspec_uuid2
61*0a6a1f1dSLionel Sambuc #if __has_declspec_attribute(__uuid__)
62*0a6a1f1dSLionel Sambuc   int has_declspec_uuid2();
63*0a6a1f1dSLionel Sambuc #endif
64*0a6a1f1dSLionel Sambuc 
65*0a6a1f1dSLionel Sambuc // CHECK: does_not_have_declspec_fallthrough
66*0a6a1f1dSLionel Sambuc #if !__has_declspec_attribute(fallthrough)
67*0a6a1f1dSLionel Sambuc   int does_not_have_declspec_fallthrough();
68*0a6a1f1dSLionel Sambuc #endif
69