Skip to content

Commit 9ef812a

Browse files
committed
\open-source-parsers#964 Delete JSONCPP_NORETURN for [[noreturn]]
This patch removes the custom JSONCPP_NORETURN macro in favor of the C++11 standard [[noreturn]] attribute.
1 parent 60ba071 commit 9ef812a

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

include/json/value.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,6 @@
2424
#include <cpptl/forwards.h>
2525
#endif
2626

27-
// Conditional NORETURN attribute on the throw functions would:
28-
// a) suppress false positives from static code analysis
29-
// b) possibly improve optimization opportunities.
30-
#if !defined(JSONCPP_NORETURN)
31-
#if defined(_MSC_VER)
32-
#define JSONCPP_NORETURN __declspec(noreturn)
33-
#elif defined(__GNUC__)
34-
#define JSONCPP_NORETURN __attribute__((__noreturn__))
35-
#else
36-
#define JSONCPP_NORETURN
37-
#endif
38-
#endif
39-
4027
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
4128
// be used by...
4229
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
@@ -89,9 +76,9 @@ class JSON_API LogicError : public Exception {
8976
#endif
9077

9178
/// used internally
92-
JSONCPP_NORETURN void throwRuntimeError(String const& msg);
79+
[[noreturn]] void throwRuntimeError(String const& msg);
9380
/// used internally
94-
JSONCPP_NORETURN void throwLogicError(String const& msg);
81+
[[noreturn]] void throwLogicError(String const& msg);
9582

9683
/** \brief Type of the value held by a Value object.
9784
*/

src/lib_json/json_value.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,15 @@ Exception::~Exception() JSONCPP_NOEXCEPT {}
232232
char const* Exception::what() const JSONCPP_NOEXCEPT { return msg_.c_str(); }
233233
RuntimeError::RuntimeError(String const& msg) : Exception(msg) {}
234234
LogicError::LogicError(String const& msg) : Exception(msg) {}
235-
JSONCPP_NORETURN void throwRuntimeError(String const& msg) {
235+
[[noreturn]] void throwRuntimeError(String const& msg) {
236236
throw RuntimeError(msg);
237237
}
238-
JSONCPP_NORETURN void throwLogicError(String const& msg) {
238+
[[noreturn]] void throwLogicError(String const& msg) {
239239
throw LogicError(msg);
240240
}
241241
#else // !JSON_USE_EXCEPTION
242-
JSONCPP_NORETURN void throwRuntimeError(String const& msg) { abort(); }
243-
JSONCPP_NORETURN void throwLogicError(String const& msg) { abort(); }
242+
[[noreturn]] void throwRuntimeError(String const& msg) { abort(); }
243+
[[noreturn]] void throwLogicError(String const& msg) { abort(); }
244244
#endif
245245

246246
// //////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)