]> https://gitweb.dealii.org/ - dealii.git/commitdiff
When using C++23, use [[assume]] attribute.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 11 Jan 2024 21:31:14 +0000 (14:31 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 6 Feb 2024 15:27:57 +0000 (08:27 -0700)
include/deal.II/base/config.h.in
include/deal.II/base/exceptions.h

index c9943b3efea1954c76f824d6e5d509d244ec3fa5..5e468bc133251629c351ca5cf12a0e7bbb8dec27 100644 (file)
  * attribute for older standards we rely on compiler intrinsics when
  * available.
  */
-#if defined(__clang__)
-#  define DEAL_II_CXX23_ASSUME(expr) __builtin_assume(static_cast<bool>(expr))
-#elif defined(__GNUC__) && !defined(__ICC) && __GNUC__ >= 13
-#  define DEAL_II_CXX23_ASSUME(expr)                                   \
+#ifdef DEAL_II_HAVE_CXX23
+#  define define DEAL_II_ASSUME(expr) [[assume(expr)]]
+#else
+#  if defined(__clang__)
+#    define DEAL_II_CXX23_ASSUME(expr) __builtin_assume(static_cast<bool>(expr))
+#  elif defined(__GNUC__) && !defined(__ICC) && __GNUC__ >= 13
+#    define DEAL_II_CXX23_ASSUME(expr)                                   \
     do                                                                 \
       {                                                                \
         _Pragma("GCC diagnostic push")                                 \
         _Pragma("GCC diagnostic pop")                                  \
       }                                                                \
     while (false)
-#elif defined(_MSC_VER) || defined(__ICC)
-#  define DEAL_II_CXX23_ASSUME(expr) __assume(expr);
-#else
+#  elif defined(_MSC_VER) || defined(__ICC)
+#    define DEAL_II_CXX23_ASSUME(expr) __assume(expr);
+#  else
 /* no way with GCC to express this without evaluating 'expr' */
-#  define DEAL_II_CXX23_ASSUME(expr) \
+#    define DEAL_II_CXX23_ASSUME(expr) \
     do                               \
       {                              \
       }                              \
     while (false)
+#  endif
 #endif
 
+
 /**
  * Macro indicating that the current feature will be removed in a future
  * release.
index 99dceb54503410ebb0167b6cc4b484be7de83b84..4adb7483baff5a626031b55efc40d4b9c89eefd6 100644 (file)
@@ -1519,6 +1519,7 @@ namespace deal_II_exceptions
 } /*namespace deal_II_exceptions*/
 
 
+
 /**
  * A macro that serves as the main routine in the exception mechanism for debug
  * mode error checking. It asserts that a certain condition is fulfilled,

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.