has_attribute.cpp 1.8 KB

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