Skip to content

Commit

Permalink
Merge pull request #16457 from bangerth/assume
Browse files Browse the repository at this point in the history
[C++23] When using C++23, use [[assume]] attribute.
  • Loading branch information
masterleinad committed Feb 19, 2024
2 parents cc045c7 + 46c0e6c commit 2e2dd3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
25 changes: 10 additions & 15 deletions include/deal.II/base/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -183,29 +183,24 @@
* 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) \
do \
{ \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") \
[[assume(expr)]]; \
_Pragma("GCC diagnostic pop") \
} \
while (false)
#elif defined(_MSC_VER) || defined(__ICC)
# define DEAL_II_CXX23_ASSUME(expr) __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(_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.
Expand Down
1 change: 1 addition & 0 deletions include/deal.II/base/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,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,
Expand Down

0 comments on commit 2e2dd3f

Please sign in to comment.