mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-26 18:51:04 +08:00
Re-add JSONCPP_NORETURN (#1041)
Fixes Visual Studio 2013 compatibility.
This commit is contained in:
parent
f34bf24bbd
commit
2ee3b1dbb1
@ -9,6 +9,18 @@
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "forwards.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
// Conditional NORETURN attribute on the throw functions would:
|
||||
// a) suppress false positives from static code analysis
|
||||
// b) possibly improve optimization opportunities.
|
||||
#if !defined(JSONCPP_NORETURN)
|
||||
#if defined(_MSC_VER) && _MSC_VER == 1800
|
||||
#define JSONCPP_NORETURN __declspec(noreturn)
|
||||
#else
|
||||
#define JSONCPP_NORETURN [[noreturn]]
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
@ -76,9 +88,9 @@ public:
|
||||
#endif
|
||||
|
||||
/// used internally
|
||||
[[noreturn]] void throwRuntimeError(String const& msg);
|
||||
JSONCPP_NORETURN void throwRuntimeError(String const& msg);
|
||||
/// used internally
|
||||
[[noreturn]] void throwLogicError(String const& msg);
|
||||
JSONCPP_NORETURN void throwLogicError(String const& msg);
|
||||
|
||||
/** \brief Type of the value held by a Value object.
|
||||
*/
|
||||
|
@ -207,13 +207,13 @@ Exception::~Exception() JSONCPP_NOEXCEPT {}
|
||||
char const* Exception::what() const JSONCPP_NOEXCEPT { return msg_.c_str(); }
|
||||
RuntimeError::RuntimeError(String const& msg) : Exception(msg) {}
|
||||
LogicError::LogicError(String const& msg) : Exception(msg) {}
|
||||
[[noreturn]] void throwRuntimeError(String const& msg) {
|
||||
JSONCPP_NORETURN void throwRuntimeError(String const& msg) {
|
||||
throw RuntimeError(msg);
|
||||
}
|
||||
[[noreturn]] void throwLogicError(String const& msg) { throw LogicError(msg); }
|
||||
JSONCPP_NORETURN void throwLogicError(String const& msg) { throw LogicError(msg); }
|
||||
#else // !JSON_USE_EXCEPTION
|
||||
[[noreturn]] void throwRuntimeError(String const& msg) { abort(); }
|
||||
[[noreturn]] void throwLogicError(String const& msg) { abort(); }
|
||||
JSONCPP_NORETURN void throwRuntimeError(String const& msg) { abort(); }
|
||||
JSONCPP_NORETURN void throwLogicError(String const& msg) { abort(); }
|
||||
#endif
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user