]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Put [[deprecated]] checks back in place
authorMatthias Maier <tamiko@43-1.org>
Fri, 22 May 2020 05:01:08 +0000 (00:01 -0500)
committerMatthias Maier <tamiko@43-1.org>
Sat, 23 May 2020 14:56:50 +0000 (09:56 -0500)
cmake/checks/check_01_cxx_features.cmake
cmake/checks/check_02_compiler_features.cmake
include/deal.II/base/config.h.in

index e41f3099256911fc400bafcdaa98cffdfee33f70..324f1995a7bc21eeb0b084d2ff85b9099868370e 100644 (file)
@@ -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 <int dim>
+          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 <int dim>
+          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
index 53b05159e8f29ed8e962acebc7c34231f48a3296..77b6eafbfce73c82683bd29ace79372f6841983a 100644 (file)
@@ -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
index 970b0053579b60a17138e06d1ddb1cf6a632bcef..8facabf5fde5081bbd9f1fcf4cfaca9d78435e89 100644 (file)
 #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@
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.