diff options
| author | Lioncash <mathew1800@gmail.com> | 2018-03-16 12:06:24 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2018-03-16 12:35:23 -0400 |
| commit | f44e2dc425c2da34498f13e9eecdcf75592ceea4 (patch) | |
| tree | 4d4f80c8997773ba9c1bbbe535ec54b56dd0d5f4 /Source/Core | |
| parent | 9f4d5122a2a1b2d0dbfd6164a616d1c859ef0d0b (diff) | |
Assert: Wrap assertion macro bodies in do {} while (0)
Enforces the termination of the macro with a semicolon. Aside from that
requirement, behavior remains the same.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Common/Assert.h | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/Source/Core/Common/Assert.h b/Source/Core/Common/Assert.h index 4ea2b50352..d1215a51f7 100644 --- a/Source/Core/Common/Assert.h +++ b/Source/Core/Common/Assert.h @@ -11,41 +11,59 @@ #ifdef _WIN32 #define ASSERT_MSG(_t_, _a_, _fmt_, ...) \ - if (!(_a_)) \ + do \ { \ - if (!PanicYesNo(_fmt_ "\n\nIgnore and continue?", __VA_ARGS__)) \ - Crash(); \ - } + if (!(_a_)) \ + { \ + if (!PanicYesNo(_fmt_ "\n\nIgnore and continue?", __VA_ARGS__)) \ + Crash(); \ + } \ + } while (0) #define DEBUG_ASSERT_MSG(_t_, _a_, _msg_, ...) \ - if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG && !(_a_)) \ + do \ { \ - ERROR_LOG(_t_, _msg_, __VA_ARGS__); \ - if (!PanicYesNo(_msg_, __VA_ARGS__)) \ - Crash(); \ - } + if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG && !(_a_)) \ + { \ + ERROR_LOG(_t_, _msg_, __VA_ARGS__); \ + if (!PanicYesNo(_msg_, __VA_ARGS__)) \ + Crash(); \ + } \ + } while (0) #else #define ASSERT_MSG(_t_, _a_, _fmt_, ...) \ - if (!(_a_)) \ + do \ { \ - if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) \ - Crash(); \ - } + if (!(_a_)) \ + { \ + if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) \ + Crash(); \ + } \ + } while (0) #define DEBUG_ASSERT_MSG(_t_, _a_, _msg_, ...) \ - if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG && !(_a_)) \ + do \ { \ - ERROR_LOG(_t_, _msg_, ##__VA_ARGS__); \ - if (!PanicYesNo(_msg_, ##__VA_ARGS__)) \ - Crash(); \ - } + if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG && !(_a_)) \ + { \ + ERROR_LOG(_t_, _msg_, ##__VA_ARGS__); \ + if (!PanicYesNo(_msg_, ##__VA_ARGS__)) \ + Crash(); \ + } \ + } while (0) #endif #define ASSERT(_a_) \ - ASSERT_MSG(MASTER_LOG, _a_, \ - _trans("An error occurred.\n\n Line: %d\n File: %s\n\nIgnore and continue?"), \ - __LINE__, __FILE__) + do \ + { \ + ASSERT_MSG(MASTER_LOG, _a_, \ + _trans("An error occurred.\n\n Line: %d\n File: %s\n\nIgnore and continue?"), \ + __LINE__, __FILE__); \ + } while (0) #define DEBUG_ASSERT(_t_, _a_) \ - if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG) \ - ASSERT(_a_) + do \ + { \ + if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG) \ + ASSERT(_a_); \ + } while (0) |
