Skip to content
Snippets Groups Projects
Commit 78e2cd1d authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add __attribut__ to help scan-build static analyzer

parent 40bf8161
Branches
Tags
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment