Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unify implementation of [[deprecated]] attribute #2934

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions libcudacxx/include/cuda/std/__cccl/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,25 @@
# define _CCCL_RESTRICT __restrict__
#endif // ^^^ !_CCCL_COMPILER(MSVC) ^^^

// prefer compiler specific way of defining deprecated because of compiler bugs in old GCC and Clang
// define deprecated macro to vendor specific attributes
#if _CCCL_COMPILER(MSVC)
# define _CCCL_DEPRECATED __declspec(deprecated)
# define _CCCL_DEPRECATED_BECAUSE(_MSG) __declspec(deprecated(_MSG))
#elif _CCCL_COMPILER(GCC) || _CCCL_COMPILER(CLANG) || _CCCL_COMPILER(NVHPC) || _CCCL_COMPILER(ICC)
#elif _CCCL_HAS_CPP_ATTRIBUTE(__deprecated__)
# define _CCCL_DEPRECATED __attribute__((__deprecated__))
# define _CCCL_DEPRECATED_BECAUSE(_MSG) __attribute__((__deprecated__(_MSG)))
#elif _CCCL_STD_VER >= 2014
# define _CCCL_DEPRECATED [[deprecated]]
# define _CCCL_DEPRECATED_BECAUSE(_MSG) [[deprecated(_MSG)]]
#else
# define _CCCL_DEPRECATED
# define _CCCL_DEPRECATED_BECAUSE(_MSG)
#endif

// use the C++14 deprecated attribute if available instead of the vendor specific ones except for GCC before 13 and
// Clang before 13 which have issues with combinig it with other attributes
bernhardmgruber marked this conversation as resolved.
Show resolved Hide resolved
#if _CCCL_STD_VER >= 2014 && !_CCCL_COMPILER(GCC, <, 13) && !_CCCL_COMPILER(CLANG, <, 13)
# undef _CCCL_DEPRECATED
# undef _CCCL_DEPRECATED_BECAUSE
# define _CCCL_DEPRECATED [[deprecated]]
# define _CCCL_DEPRECATED_BECAUSE(_MSG) [[deprecated(_MSG)]]
#endif

#endif // __CCCL_ATTRIBUTES_H