File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 2222#include < cpptl/forwards.h>
2323#endif
2424
25+ // Conditional NORETURN attribute on the throw functions would:
26+ // a) suppress false positives from static code analysis
27+ // b) possibly improve optimization opportunities.
28+ #if !defined(JSONCPP_NORETURN)
29+ # if defined(_MSC_VER)
30+ # define JSONCPP_NORETURN __declspec (noreturn)
31+ # elif defined(__GNUC__)
32+ # define JSONCPP_NORETURN __attribute__ ((__noreturn__))
33+ # else
34+ # define JSONCPP_NORETURN
35+ # endif
36+ #endif
37+
2538// Disable warning C4251: <data member>: <type> needs to have dll-interface to
2639// be used by...
2740#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
@@ -69,9 +82,9 @@ class JSON_API LogicError : public Exception {
6982};
7083
7184// / used internally
72- void throwRuntimeError (JSONCPP_STRING const & msg);
85+ JSONCPP_NORETURN void throwRuntimeError (JSONCPP_STRING const & msg);
7386// / used internally
74- void throwLogicError (JSONCPP_STRING const & msg);
87+ JSONCPP_NORETURN void throwLogicError (JSONCPP_STRING const & msg);
7588
7689/* * \brief Type of the value held by a Value object.
7790 */
Original file line number Diff line number Diff line change @@ -171,11 +171,11 @@ RuntimeError::RuntimeError(JSONCPP_STRING const& msg)
171171LogicError::LogicError (JSONCPP_STRING const & msg)
172172 : Exception(msg)
173173{}
174- void throwRuntimeError (JSONCPP_STRING const & msg)
174+ JSONCPP_NORETURN void throwRuntimeError (JSONCPP_STRING const & msg)
175175{
176176 throw RuntimeError (msg);
177177}
178- void throwLogicError (JSONCPP_STRING const & msg)
178+ JSONCPP_NORETURN void throwLogicError (JSONCPP_STRING const & msg)
179179{
180180 throw LogicError (msg);
181181}
You can’t perform that action at this time.
0 commit comments