File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 99#if !defined(JSON_IS_AMALGAMATION)
1010#include " forwards.h"
1111#endif // if !defined(JSON_IS_AMALGAMATION)
12+
13+ // Conditional NORETURN attribute on the throw functions would:
14+ // a) suppress false positives from static code analysis
15+ // b) possibly improve optimization opportunities.
16+ #if !defined(JSONCPP_NORETURN)
17+ #if defined(_MSC_VER) && _MSC_VER == 1800
18+ #define JSONCPP_NORETURN __declspec (noreturn)
19+ #else
20+ #define JSONCPP_NORETURN [[noreturn]]
21+ #endif
22+ #endif
23+
1224#include < array>
1325#include < exception>
1426#include < memory>
@@ -76,9 +88,9 @@ class JSON_API LogicError : public Exception {
7688#endif
7789
7890// / used internally
79- [[noreturn]] void throwRuntimeError (String const & msg);
91+ JSONCPP_NORETURN void throwRuntimeError (String const & msg);
8092// / used internally
81- [[noreturn]] void throwLogicError (String const & msg);
93+ JSONCPP_NORETURN void throwLogicError (String const & msg);
8294
8395/* * \brief Type of the value held by a Value object.
8496 */
Original file line number Diff line number Diff line change @@ -207,13 +207,13 @@ Exception::~Exception() JSONCPP_NOEXCEPT {}
207207char const * Exception::what () const JSONCPP_NOEXCEPT { return msg_.c_str (); }
208208RuntimeError::RuntimeError (String const & msg) : Exception(msg) {}
209209LogicError::LogicError (String const & msg) : Exception(msg) {}
210- [[noreturn]] void throwRuntimeError (String const & msg) {
210+ JSONCPP_NORETURN void throwRuntimeError (String const & msg) {
211211 throw RuntimeError (msg);
212212}
213- [[noreturn]] void throwLogicError (String const & msg) { throw LogicError (msg); }
213+ JSONCPP_NORETURN void throwLogicError (String const & msg) { throw LogicError (msg); }
214214#else // !JSON_USE_EXCEPTION
215- [[noreturn]] void throwRuntimeError (String const & msg) { abort (); }
216- [[noreturn]] void throwLogicError (String const & msg) { abort (); }
215+ JSONCPP_NORETURN void throwRuntimeError (String const & msg) { abort (); }
216+ JSONCPP_NORETURN void throwLogicError (String const & msg) { abort (); }
217217#endif
218218
219219// //////////////////////////////////////////////////////////////////
You can’t perform that action at this time.
0 commit comments