Files
TheRock/compiler/amd-llvm/clang/test/Preprocessor/has_attribute.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

162 lines
3.9 KiB
C++

// 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=:
// 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=:
// RUN: %clang_cc1 -triple i386-windows -fms-compatibility -std=c++03 -E -P %s -o - | FileCheck %s --check-prefixes=CHECK,WINDOWS --implicit-check-not=:
// RUN: %clang_cc1 -triple i386-windows -fms-compatibility -std=c++11 -E -P %s -o - | FileCheck %s --check-prefixes=CHECK,WINDOWS --implicit-check-not=:
#define CXX11(x) x: __has_cpp_attribute(x)
// CHECK: clang::fallthrough: 1
CXX11(clang::fallthrough)
// CHECK: selectany: 0
CXX11(selectany)
// The attribute name can be bracketed with double underscores.
// CHECK: clang::__fallthrough__: 1
CXX11(clang::__fallthrough__)
// The scope cannot be bracketed with double underscores unless it is
// for gnu or clang.
// CHECK: __gsl__::suppress: 0
CXX11(__gsl__::suppress)
// CHECK: _Clang::fallthrough: 1
CXX11(_Clang::fallthrough)
// CHECK: __nodiscard__: 201907L
CXX11(__nodiscard__)
// CHECK: warn_unused_result: 0
CXX11(warn_unused_result)
// CHECK: gnu::warn_unused_result: 1
CXX11(gnu::warn_unused_result)
// CHECK: clang::warn_unused_result: 1
CXX11(clang::warn_unused_result)
// CHECK: __gnu__::__const__: 1
CXX11(__gnu__::__const__)
// Test that C++11, target-specific attributes behave properly.
// CHECK: gnu::mips16: 0
CXX11(gnu::mips16)
// Test for standard attributes as listed in C++2a [cpp.cond] paragraph 6.
CXX11(assert)
CXX11(carries_dependency)
CXX11(deprecated)
CXX11(ensures)
CXX11(expects)
CXX11(fallthrough)
CXX11(likely)
CXX11(maybe_unused)
CXX11(no_unique_address)
CXX11(msvc::no_unique_address)
CXX11(nodiscard)
CXX11(noreturn)
CXX11(unlikely)
// FIXME(201806L) CHECK: assert: 0
// CHECK: carries_dependency: 200809L
// CHECK: deprecated: 201309L
// FIXME(201806L) CHECK: ensures: 0
// FIXME(201806L) CHECK: expects: 0
// CHECK: fallthrough: 201603L
// CHECK: likely: 201803L
// CHECK: maybe_unused: 201603L
// ITANIUM: no_unique_address: 201803L
// WINDOWS: no_unique_address: 0
// ITANIUM: msvc::no_unique_address: 0
// WINDOWS: msvc::no_unique_address: 201803L
// CHECK: nodiscard: 201907L
// CHECK: noreturn: 200809L
// CHECK: unlikely: 201803L
namespace PR48462 {
// Test that macro expansion of the builtin argument works.
#define C clang
#define F fallthrough
#define CF clang::fallthrough
#if __has_cpp_attribute(F)
int has_fallthrough;
#endif
// CHECK: int has_fallthrough;
#if __has_cpp_attribute(C::F)
int has_clang_falthrough_1;
#endif
// CHECK: int has_clang_falthrough_1;
#if __has_cpp_attribute(clang::F)
int has_clang_falthrough_2;
#endif
// CHECK: int has_clang_falthrough_2;
#if __has_cpp_attribute(C::fallthrough)
int has_clang_falthrough_3;
#endif
// CHECK: int has_clang_falthrough_3;
#if __has_cpp_attribute(CF)
int has_clang_falthrough_4;
#endif
// CHECK: int has_clang_falthrough_4;
#define FUNCLIKE1(x) clang::x
#if __has_cpp_attribute(FUNCLIKE1(fallthrough))
int funclike_1;
#endif
// CHECK: int funclike_1;
#define FUNCLIKE2(x) _Clang::x
#if __has_cpp_attribute(FUNCLIKE2(fallthrough))
int funclike_2;
#endif
// CHECK: int funclike_2;
#if __has_cpp_attribute(CF\
)
int has_clang_falthrough_5;
#endif
// CHECK: int has_clang_falthrough_5;
#define CF_2 clang::\
fallthrough
#if __has_cpp_attribute(CF_2)
int has_clang_falthrough_6;
#endif
// CHECK: int has_clang_falthrough_6;
#if __has_cpp_attribute(CF_2\
)
int has_clang_falthrough_7;
#endif
// CHECK: int has_clang_falthrough_7;
}
// Test for Microsoft __declspec attributes
#define DECLSPEC(x) x: __has_declspec_attribute(x)
// CHECK: uuid: 1
// CHECK: __uuid__: 1
DECLSPEC(uuid)
DECLSPEC(__uuid__)
// CHECK: fallthrough: 0
DECLSPEC(fallthrough)
namespace PR48462 {
// Test that macro expansion of the builtin argument works.
#define U uuid
#if __has_declspec_attribute(U)
int has_uuid;
#endif
// CHECK: int has_uuid;
}