From d97ea5bf8d54f30dd127e2c563f44a861440864e Mon Sep 17 00:00:00 2001 From: Gaurav Date: Wed, 16 Mar 2016 11:15:09 +0530 Subject: [PATCH] Added NORETURN for throw functions. Resolve Issue - https://github.com/open-source-parsers/jsoncpp/issues/389 --- include/json/value.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/include/json/value.h b/include/json/value.h index 08ae6f6..5948935 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -22,6 +22,19 @@ #include #endif +//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) +# define JSONCPP_NORETURN __declspec(noreturn) +# elif defined(__GNUC__) +# define JSONCPP_NORETURN __attribute__ ((__noreturn__)) +# else +# define JSONCPP_NORETURN +# endif +#endif + // Disable warning C4251: : needs to have dll-interface to // be used by... #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) @@ -69,9 +82,9 @@ public: }; /// used internally -void throwRuntimeError(JSONCPP_STRING const& msg); +JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg); /// used internally -void throwLogicError(JSONCPP_STRING const& msg); +JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg); /** \brief Type of the value held by a Value object. */