diff --git a/src/utils/PastisAssert.hpp b/src/utils/PastisAssert.hpp index 9f5a171ac0b723ee553fb2a71b15e3d2743d6340..d260ce25f293e955c0bbfbaa66861345658f9995 100644 --- a/src/utils/PastisAssert.hpp +++ b/src/utils/PastisAssert.hpp @@ -45,19 +45,29 @@ class AssertError ~AssertError() = default; }; +#pragma GCC diagnostic ignored "-Wattributes" +inline bool +__attribute__((analyzer_noreturn)) +_pastis_assert(const bool& assert) +{ + return assert; +} +#pragma GCC diagnostic pop + #ifdef NDEBUG // Useless test is there to check syntax even in optimized mode. Costs nothing. -#define Assert(assertion) if (not (assertion)) {} +#define Assert(assertion) \ + if (not _pastis_assert(assertion)) {} #else // NDEBUG -#define Assert(assertion) \ - if (not (assertion)) { \ - throw AssertError(__FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__, \ - (#assertion)); \ +#define Assert(assertion) \ + if (not _pastis_assert(assertion)) { \ + throw AssertError(__FILE__, \ + __LINE__, \ + __PRETTY_FUNCTION__, \ + (#assertion)); \ } #endif // NDEBUG