Re-add JSONCPP_NORETURN (#1041)
Fixes Visual Studio 2013 compatibility.
diff --git a/include/json/value.h b/include/json/value.h
index a0a5a11..7efc7c5 100644
--- a/include/json/value.h
+++ b/include/json/value.h
@@ -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 @@
#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.
*/
diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp
index cf93ec7..30d9ad8 100644
--- a/src/lib_json/json_value.cpp
+++ b/src/lib_json/json_value.cpp
@@ -207,13 +207,13 @@
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
// //////////////////////////////////////////////////////////////////