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
Show file tree
Hide file tree
Changes from 9 commits
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
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ AttributeMacros: [
'_CCCL_NODISCARD_FRIEND',
'_CCCL_NODISCARD',
'_CCCL_NORETURN',
'_CCCL_DEPRECATED',
'_CCCL_DEPRECATED_BECAUSE',
'_CCCL_TYPE_VISIBILITY_DEFAULT',
'_CCCL_VISIBILITY_HIDDEN',
'CUB_RUNTIME_FUNCTION',
Expand Down
16 changes: 2 additions & 14 deletions cub/cub/util_deprecated.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,9 @@
#ifdef CUB_IGNORE_DEPRECATED_API
# define CUB_DEPRECATED
# define CUB_DEPRECATED_BECAUSE(MSG)
#elif _CCCL_STD_VER >= 2014
# define CUB_DEPRECATED [[deprecated]]
# define CUB_DEPRECATED_BECAUSE(MSG) [[deprecated(MSG)]]
#elif _CCCL_COMPILER(MSVC)
# define CUB_DEPRECATED __declspec(deprecated)
# define CUB_DEPRECATED_BECAUSE(MSG) __declspec(deprecated(MSG))
#elif _CCCL_COMPILER(CLANG)
# define CUB_DEPRECATED __attribute__((deprecated))
# define CUB_DEPRECATED_BECAUSE(MSG) __attribute__((deprecated(MSG)))
#elif _CCCL_COMPILER(GCC)
# define CUB_DEPRECATED __attribute__((deprecated))
# define CUB_DEPRECATED_BECAUSE(MSG) __attribute__((deprecated(MSG)))
#else
# define CUB_DEPRECATED
# define CUB_DEPRECATED_BECAUSE(MSG)
# define CUB_DEPRECATED _CCCL_DEPRECATED
# define CUB_DEPRECATED_BECAUSE(MSG) _CCCL_DEPRECATED_BECAUSE(MSG)
#endif

#define CUB_DETAIL_RUNTIME_DEBUG_SYNC_IS_NOT_SUPPORTED \
Expand Down
22 changes: 22 additions & 0 deletions libcudacxx/include/cuda/std/__cccl/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,26 @@
# define _CCCL_RESTRICT __restrict__
#endif // ^^^ !_CCCL_COMPILER(MSVC) ^^^

// 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_HAS_ATTRIBUTE(__deprecated__)
# define _CCCL_DEPRECATED __attribute__((__deprecated__))
# define _CCCL_DEPRECATED_BECAUSE(_MSG) __attribute__((__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_HAS_CPP_ATTRIBUTE(deprecated) && !_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
Original file line number Diff line number Diff line change
Expand Up @@ -630,13 +630,7 @@ typedef unsigned int char32_t;
// by defining _LIBCUDACXX_DISABLE_DEPRECATION_WARNINGS.
// NVCC 11.1 and 11.2 are broken with the deprecated attribute, so disable it
# if !defined(_LIBCUDACXX_DISABLE_DEPRECATION_WARNINGS) && _CCCL_CUDACC_AT_LEAST(11, 3)
# if _CCCL_HAS_ATTRIBUTE(deprecated)
# define _LIBCUDACXX_DEPRECATED __attribute__((deprecated))
# elif _CCCL_STD_VER > 2011
# define _LIBCUDACXX_DEPRECATED [[deprecated]]
# else
# define _LIBCUDACXX_DEPRECATED
# endif
# define _LIBCUDACXX_DEPRECATED _CCCL_DEPRECATED
# else
# define _LIBCUDACXX_DEPRECATED
# endif
Expand Down
16 changes: 2 additions & 14 deletions thrust/thrust/detail/config/deprecated.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,7 @@
#ifdef THRUST_IGNORE_DEPRECATED_API
# define THRUST_DEPRECATED
# define THRUST_DEPRECATED_BECAUSE(MSG)
#elif _CCCL_STD_VER >= 2014
# define THRUST_DEPRECATED [[deprecated]]
# define THRUST_DEPRECATED_BECAUSE(MSG) [[deprecated(MSG)]]
#elif _CCCL_COMPILER(MSVC)
# define THRUST_DEPRECATED __declspec(deprecated)
# define THRUST_DEPRECATED_BECAUSE(MSG) __declspec(deprecated(MSG))
#elif _CCCL_COMPILER(CLANG)
# define THRUST_DEPRECATED __attribute__((deprecated))
# define THRUST_DEPRECATED_BECAUSE(MSG) __attribute__((deprecated(MSG)))
#elif _CCCL_COMPILER(GCC)
# define THRUST_DEPRECATED __attribute__((deprecated))
# define THRUST_DEPRECATED_BECAUSE(MSG) __attribute__((deprecated(MSG)))
#else
# define THRUST_DEPRECATED
# define THRUST_DEPRECATED_BECAUSE(MSG)
# define THRUST_DEPRECATED _CCCL_DEPRECATED
# define THRUST_DEPRECATED_BECAUSE(MSG) _CCCL_DEPRECATED_BECAUSE(MSG)
#endif