From f158b227b12d1294ea75cf90803b2e1a67061a1b Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Fri, 22 May 2020 00:01:08 -0500 Subject: [PATCH] CMake: Put [[deprecated]] checks back in place --- cmake/checks/check_01_cxx_features.cmake | 69 ++++++++++++++++++- cmake/checks/check_02_compiler_features.cmake | 1 - include/deal.II/base/config.h.in | 2 +- 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/cmake/checks/check_01_cxx_features.cmake b/cmake/checks/check_01_cxx_features.cmake index e41f309925..324f1995a7 100644 --- a/cmake/checks/check_01_cxx_features.cmake +++ b/cmake/checks/check_01_cxx_features.cmake @@ -23,6 +23,7 @@ # DEAL_II_HAVE_FP_EXCEPTIONS # DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS # DEAL_II_FALLTHROUGH +# DEAL_II_DEPRECATED # DEAL_II_CONSTEXPR # @@ -346,6 +347,73 @@ CHECK_CXX_SOURCE_COMPILES( DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS) +# +# Even though [[deprecated]] is a C++14 feature we have to check +# wether 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_COMPILER_HAS_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_COMPILER_HAS_ATTRIBUTE_DEPRECATED + ) + +IF(DEAL_II_COMPILER_HAS_CXX17_ATTRIBUTE_DEPRECATED) + SET(DEAL_II_DEPRECATED "[[deprecated]]") +ELSEIF(DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED AND NOT DEAL_II_WITH_CUDA) + SET(DEAL_II_DEPRECATED "__attribute__((deprecated))") +ELSE() + SET(DEAL_II_DEPRECATED " ") +ENDIF() + + # # Try to enable a fallthrough attribute. This is a language feature in C++17, # but a compiler extension in earlier language versions. @@ -372,7 +440,6 @@ CHECK_CXX_SOURCE_COMPILES( DEAL_II_HAVE_CXX17_ATTRIBUTE_FALLTHROUGH ) - # # see if the current compiler configuration supports the GCC extension # __attribute__((fallthrough)) syntax instead diff --git a/cmake/checks/check_02_compiler_features.cmake b/cmake/checks/check_02_compiler_features.cmake index 53b05159e8..77b6eafbfc 100644 --- a/cmake/checks/check_02_compiler_features.cmake +++ b/cmake/checks/check_02_compiler_features.cmake @@ -28,7 +28,6 @@ # DEAL_II_HAVE_GLIBC_STACKTRACE # DEAL_II_HAVE_LIBSTDCXX_DEMANGLER # DEAL_II_COMPILER_HAS_ATTRIBUTE_PRETTY_FUNCTION -# DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED # DEAL_II_COMPILER_HAS_ATTRIBUTE_ALWAYS_INLINE # DEAL_II_ALWAYS_INLINE # DEAL_II_RESTRICT diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index 970b005357..8facabf5fd 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -141,7 +141,7 @@ #cmakedefine DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS #cmakedefine DEAL_II_CXX14_CONSTEXPR_BUG_OK -#define DEAL_II_DEPRECATED [[deprecated]] +#cmakedefine DEAL_II_DEPRECATED @DEAL_II_DEPRECATED@ #cmakedefine DEAL_II_FALLTHROUGH @DEAL_II_FALLTHROUGH@ #cmakedefine DEAL_II_CONSTEXPR @DEAL_II_CONSTEXPR@ -- 2.39.5