File tree 2 files changed +18
-6
lines changed
2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 9
9
#if !defined(JSON_IS_AMALGAMATION)
10
10
#include " forwards.h"
11
11
#endif // if !defined(JSON_IS_AMALGAMATION)
12
+
13
+ // Conditional NORETURN attribute on the throw functions would:
14
+ // a) suppress false positives from static code analysis
15
+ // b) possibly improve optimization opportunities.
16
+ #if !defined(JSONCPP_NORETURN)
17
+ #if defined(_MSC_VER) && _MSC_VER == 1800
18
+ #define JSONCPP_NORETURN __declspec (noreturn)
19
+ #else
20
+ #define JSONCPP_NORETURN [[noreturn]]
21
+ #endif
22
+ #endif
23
+
12
24
#include < array>
13
25
#include < exception>
14
26
#include < memory>
@@ -76,9 +88,9 @@ class JSON_API LogicError : public Exception {
76
88
#endif
77
89
78
90
// / used internally
79
- [[noreturn]] void throwRuntimeError (String const & msg);
91
+ JSONCPP_NORETURN void throwRuntimeError (String const & msg);
80
92
// / used internally
81
- [[noreturn]] void throwLogicError (String const & msg);
93
+ JSONCPP_NORETURN void throwLogicError (String const & msg);
82
94
83
95
/* * \brief Type of the value held by a Value object.
84
96
*/
Original file line number Diff line number Diff line change @@ -207,13 +207,13 @@ Exception::~Exception() JSONCPP_NOEXCEPT {}
207
207
char const * Exception::what () const JSONCPP_NOEXCEPT { return msg_.c_str (); }
208
208
RuntimeError::RuntimeError (String const & msg) : Exception(msg) {}
209
209
LogicError::LogicError (String const & msg) : Exception(msg) {}
210
- [[noreturn]] void throwRuntimeError (String const & msg) {
210
+ JSONCPP_NORETURN void throwRuntimeError (String const & msg) {
211
211
throw RuntimeError (msg);
212
212
}
213
- [[noreturn]] void throwLogicError (String const & msg) { throw LogicError (msg); }
213
+ JSONCPP_NORETURN void throwLogicError (String const & msg) { throw LogicError (msg); }
214
214
#else // !JSON_USE_EXCEPTION
215
- [[noreturn]] void throwRuntimeError (String const & msg) { abort (); }
216
- [[noreturn]] void throwLogicError (String const & msg) { abort (); }
215
+ JSONCPP_NORETURN void throwRuntimeError (String const & msg) { abort (); }
216
+ JSONCPP_NORETURN void throwLogicError (String const & msg) { abort (); }
217
217
#endif
218
218
219
219
// //////////////////////////////////////////////////////////////////
You can’t perform that action at this time.
0 commit comments