| 1 | // RUN: %clang_cc1 -triple i386-unknown-unknown -fms-compatibility -std=c++11 -E %s -o - | FileCheck %s |
| 2 | |
| 3 | // CHECK: has_cxx11_carries_dep |
| 4 | #if __has_cpp_attribute(carries_dependency) |
| 5 | int has_cxx11_carries_dep(); |
| 6 | #endif |
| 7 | |
| 8 | // CHECK: has_clang_fallthrough_1 |
| 9 | #if __has_cpp_attribute(clang::fallthrough) |
| 10 | int has_clang_fallthrough_1(); |
| 11 | #endif |
| 12 | |
| 13 | // CHECK: does_not_have_selectany |
| 14 | #if !__has_cpp_attribute(selectany) |
| 15 | int does_not_have_selectany(); |
| 16 | #endif |
| 17 | |
| 18 | // The attribute name can be bracketed with double underscores. |
| 19 | // CHECK: has_clang_fallthrough_2 |
| 20 | #if __has_cpp_attribute(clang::__fallthrough__) |
| 21 | int has_clang_fallthrough_2(); |
| 22 | #endif |
| 23 | |
| 24 | // The scope cannot be bracketed with double underscores unless it is |
| 25 | // for gnu or clang. |
| 26 | // CHECK: does_not_have___gsl___suppress |
| 27 | #if !__has_cpp_attribute(__gsl__::suppress) |
| 28 | int does_not_have___gsl___suppress(); |
| 29 | #endif |
| 30 | |
| 31 | // We do somewhat support the __clang__ vendor namespace, but it is a |
| 32 | // predefined macro and thus we encourage users to use _Clang instead. |
| 33 | // Because of this, we do not support __has_cpp_attribute for that |
| 34 | // vendor namespace. |
| 35 | // CHECK: does_not_have___clang___fallthrough |
| 36 | #if !__has_cpp_attribute(__clang__::fallthrough) |
| 37 | int does_not_have___clang___fallthrough(); |
| 38 | #endif |
| 39 | |
| 40 | // CHECK: does_have_Clang_fallthrough |
| 41 | #if __has_cpp_attribute(_Clang::fallthrough) |
| 42 | int does_have_Clang_fallthrough(); |
| 43 | #endif |
| 44 | |
| 45 | // CHECK: has_gnu_const |
| 46 | #if __has_cpp_attribute(__gnu__::__const__) |
| 47 | int has_gnu_const(); |
| 48 | #endif
|
| 49 |
|
| 50 | // Test that C++11, target-specific attributes behave properly.
|
| 51 |
|
| 52 | // CHECK: does_not_have_mips16 |
| 53 | #if !__has_cpp_attribute(gnu::mips16) |
| 54 | int does_not_have_mips16(); |
| 55 | #endif |
| 56 | |
| 57 | // Test that the version numbers of attributes listed in SD-6 are supported |
| 58 | // correctly. |
| 59 | |
| 60 | // CHECK: has_cxx11_carries_dep_vers |
| 61 | #if __has_cpp_attribute(carries_dependency) == 200809 |
| 62 | int has_cxx11_carries_dep_vers(); |
| 63 | #endif |
| 64 | |
| 65 | // CHECK: has_cxx11_noreturn_vers |
| 66 | #if __has_cpp_attribute(noreturn) == 200809 |
| 67 | int has_cxx11_noreturn_vers(); |
| 68 | #endif |
| 69 | |
| 70 | // CHECK: has_cxx14_deprecated_vers |
| 71 | #if __has_cpp_attribute(deprecated) == 201309 |
| 72 | int has_cxx14_deprecated_vers(); |
| 73 | #endif |
| 74 | |
| 75 | // CHECK: has_cxx1z_nodiscard |
| 76 | #if __has_cpp_attribute(nodiscard) == 201603 |
| 77 | int has_cxx1z_nodiscard(); |
| 78 | #endif |
| 79 | |
| 80 | // CHECK: has_cxx1z_fallthrough |
| 81 | #if __has_cpp_attribute(fallthrough) == 201603 |
| 82 | int has_cxx1z_fallthrough(); |
| 83 | #endif |
| 84 | |
| 85 | // CHECK: has_declspec_uuid |
| 86 | #if __has_declspec_attribute(uuid) |
| 87 | int has_declspec_uuid(); |
| 88 | #endif |
| 89 | |
| 90 | // CHECK: has_declspec_uuid2 |
| 91 | #if __has_declspec_attribute(__uuid__) |
| 92 | int has_declspec_uuid2(); |
| 93 | #endif |
| 94 | |
| 95 | // CHECK: does_not_have_declspec_fallthrough |
| 96 | #if !__has_declspec_attribute(fallthrough) |
| 97 | int does_not_have_declspec_fallthrough(); |
| 98 | #endif |
| 99 | |