From: Daniel Arndt Date: Thu, 6 Jul 2023 21:41:27 +0000 (-0400) Subject: Introduce DEAL_II[_DEPRECATED_EARLY]_WITH_COMMENT X-Git-Tag: relicensing~726^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d43b79eb262551accdd8dc02c138f29e41011018;p=dealii.git Introduce DEAL_II[_DEPRECATED_EARLY]_WITH_COMMENT --- diff --git a/cmake/checks/check_01_cxx_features.cmake b/cmake/checks/check_01_cxx_features.cmake index da8701b5c8..b06e86256b 100644 --- a/cmake/checks/check_01_cxx_features.cmake +++ b/cmake/checks/check_01_cxx_features.cmake @@ -26,8 +26,6 @@ # DEAL_II_HAVE_CXX17_BESSEL_FUNCTIONS # DEAL_II_HAVE_CXX17_LEGENDRE_FUNCTIONS # DEAL_II_FALLTHROUGH -# DEAL_II_DEPRECATED -# DEAL_II_DEPRECATED_EARLY # DEAL_II_CONSTEXPR # @@ -376,8 +374,6 @@ unset_if_changed(CHECK_CXX_FEATURES_FLAGS_SAVED "${CMAKE_REQUIRED_FLAGS}${CMAKE_CXX_STANDARD}" DEAL_II_HAVE_FP_EXCEPTIONS DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS - DEAL_II_HAVE_CXX17_ATTRIBUTE_DEPRECATED - DEAL_II_HAVE_ATTRIBUTE_DEPRECATED DEAL_II_HAVE_CXX17_ATTRIBUTE_FALLTHROUGH DEAL_II_HAVE_ATTRIBUTE_FALLTHROUGH DEAL_II_HAVE_CXX17_BESSEL_FUNCTIONS @@ -448,79 +444,6 @@ CHECK_CXX_SOURCE_COMPILES( " DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS) - -# -# Even though [[deprecated]] is a C++14 feature we have to check -# whether we can actually use the [[deprecated]] attribute in all -# cases we care about; some of the following are C++17 features. -# -CHECK_CXX_SOURCE_COMPILES( - " - [[deprecated]] int old_fn (); - int old_fn () { return 0; } - - struct [[deprecated]] bob - { - [[deprecated]] bob(int i); - [[deprecated]] void test(); - }; - - enum color - { - red [[deprecated]] - }; - - template - struct foo {}; - using bar [[deprecated]] = foo<2>; - - int main () {} - " - DEAL_II_HAVE_CXX17_ATTRIBUTE_DEPRECATED - ) - -# -# Also test the corresponding GCC extension -# -CHECK_CXX_SOURCE_COMPILES( - " - __attribute__((deprecated)) int old_fn (); - int old_fn () { return 0; } - - struct __attribute__((deprecated)) bob - { - __attribute__((deprecated)) bob(int i); - __attribute__((deprecated)) void test(); - }; - - enum color - { - red __attribute__((deprecated)) - }; - - template - struct foo {}; - using bar __attribute__((deprecated)) = foo<2>; - - int main () {} - " - DEAL_II_HAVE_ATTRIBUTE_DEPRECATED - ) - -if(DEAL_II_HAVE_CXX17_ATTRIBUTE_DEPRECATED) - set(DEAL_II_DEPRECATED "[[deprecated]]") -elseif(DEAL_II_HAVE_ATTRIBUTE_DEPRECATED AND NOT DEAL_II_WITH_CUDA) - set(DEAL_II_DEPRECATED "__attribute__((deprecated))") -else() - set(DEAL_II_DEPRECATED " ") -endif() -if(DEAL_II_EARLY_DEPRECATIONS) - set(DEAL_II_DEPRECATED_EARLY ${DEAL_II_DEPRECATED}) -else() - set(DEAL_II_DEPRECATED_EARLY " ") -endif() - - # # Try to enable a fallthrough attribute. This is a language feature in C++17, # but a compiler extension in earlier language versions. diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index 6218b7bbd7..6b3fcf0656 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -172,7 +172,8 @@ * Macro indicating that the current feature will be removed in a future * release. */ -#cmakedefine DEAL_II_DEPRECATED @DEAL_II_DEPRECATED@ +#define DEAL_II_DEPRECATED [[deprecated]] +#define DEAL_II_DEPRECATED_WITH_COMMENT(comment) [[deprecated(comment)]] /** * Same as above, but for things that have been deprecated during the current @@ -180,10 +181,25 @@ * deprecated prior to a release until after that release has been * finalized - see DEAL_II_EARLY_DEPRECATIONS for more information. */ +#cmakedefine DEAL_II_EARLY_DEPRECATIONS #ifndef DEAL_II_DEPRECATED_EARLY // guard to allow user to override DEAL_II_DEPRECATED_EARLY -#cmakedefine DEAL_II_DEPRECATED_EARLY @DEAL_II_DEPRECATED_EARLY@ +#ifdef DEAL_II_EARLY_DEPRECATIONS +#define DEAL_II_DEPRECATED_EARLY [[deprecated]] +#else +#define DEAL_II_DEPRECATED_EARLY +#endif +#endif + +#ifndef DEAL_II_DEPRECATED_EARLY_WITH_COMMENT +// guard to allow user to override DEAL_II_DEPRECATED_EARLY +#ifdef DEAL_II_EARLY_DEPRECATIONS +#define DEAL_II_DEPRECATED_EARLY_WITH_COMMENT(comment) [[deprecated(comment)]] +#else +#define DEAL_II_DEPRECATED_EARLY_WITH_COMMENT(comment) #endif +#endif + #cmakedefine DEAL_II_FALLTHROUGH @DEAL_II_FALLTHROUGH@ #cmakedefine DEAL_II_CONSTEXPR @DEAL_II_CONSTEXPR@