From a56a33bdf310006b3f0140884bdf55c9c6f90764 Mon Sep 17 00:00:00 2001 From: g Date: Fri, 17 Mar 2017 14:13:11 -0700 Subject: [PATCH 1/2] noexcept fix for visual studio --- CONTRIBUTING.md | 2 +- include/yaml-cpp/exceptions.h | 36 +++++++++++++++++++++-------------- src/exceptions.cpp | 26 ++++++++++++------------- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd09a1a..18d182a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,7 +17,7 @@ Commit messages should be in the imperative mood, as described in the [Git contr # Tests -Please verify the tests pass by running the target `tests/run_tests`. +Please verify the tests pass by running the target `test/run-tests`. If you are adding functionality, add tests accordingly. diff --git a/include/yaml-cpp/exceptions.h b/include/yaml-cpp/exceptions.h index a0b7e3c..a2dccaf 100644 --- a/include/yaml-cpp/exceptions.h +++ b/include/yaml-cpp/exceptions.h @@ -7,6 +7,14 @@ #pragma once #endif +#ifndef NOEXCEPT +#ifndef _MSC_VER +#define NOEXCEPT noexcept +#else +#define NOEXCEPT _NOEXCEPT +#endif +#endif + #include "yaml-cpp/mark.h" #include "yaml-cpp/traits.h" #include @@ -112,7 +120,7 @@ class YAML_CPP_API Exception : public std::runtime_error { public: Exception(const Mark& mark_, const std::string& msg_) : std::runtime_error(build_what(mark_, msg_)), mark(mark_), msg(msg_) {} - virtual ~Exception() noexcept; + virtual ~Exception() NOEXCEPT; Exception(const Exception&) = default; @@ -138,7 +146,7 @@ class YAML_CPP_API ParserException : public Exception { ParserException(const Mark& mark_, const std::string& msg_) : Exception(mark_, msg_) {} ParserException(const ParserException&) = default; - virtual ~ParserException() noexcept; + virtual ~ParserException() NOEXCEPT; }; class YAML_CPP_API RepresentationException : public Exception { @@ -146,7 +154,7 @@ class YAML_CPP_API RepresentationException : public Exception { RepresentationException(const Mark& mark_, const std::string& msg_) : Exception(mark_, msg_) {} RepresentationException(const RepresentationException&) = default; - virtual ~RepresentationException() noexcept; + virtual ~RepresentationException() NOEXCEPT; }; // representation exceptions @@ -155,7 +163,7 @@ class YAML_CPP_API InvalidScalar : public RepresentationException { InvalidScalar(const Mark& mark_) : RepresentationException(mark_, ErrorMsg::INVALID_SCALAR) {} InvalidScalar(const InvalidScalar&) = default; - virtual ~InvalidScalar() noexcept; + virtual ~InvalidScalar() NOEXCEPT; }; class YAML_CPP_API KeyNotFound : public RepresentationException { @@ -165,7 +173,7 @@ class YAML_CPP_API KeyNotFound : public RepresentationException { : RepresentationException(mark_, ErrorMsg::KEY_NOT_FOUND_WITH_KEY(key_)) { } KeyNotFound(const KeyNotFound&) = default; - virtual ~KeyNotFound() noexcept; + virtual ~KeyNotFound() NOEXCEPT; }; template @@ -173,7 +181,7 @@ class YAML_CPP_API TypedKeyNotFound : public KeyNotFound { public: TypedKeyNotFound(const Mark& mark_, const T& key_) : KeyNotFound(mark_, key_), key(key_) {} - virtual ~TypedKeyNotFound() noexcept {} + virtual ~TypedKeyNotFound() NOEXCEPT {} T key; }; @@ -189,7 +197,7 @@ class YAML_CPP_API InvalidNode : public RepresentationException { InvalidNode() : RepresentationException(Mark::null_mark(), ErrorMsg::INVALID_NODE) {} InvalidNode(const InvalidNode&) = default; - virtual ~InvalidNode() noexcept; + virtual ~InvalidNode() NOEXCEPT; }; class YAML_CPP_API BadConversion : public RepresentationException { @@ -197,7 +205,7 @@ class YAML_CPP_API BadConversion : public RepresentationException { explicit BadConversion(const Mark& mark_) : RepresentationException(mark_, ErrorMsg::BAD_CONVERSION) {} BadConversion(const BadConversion&) = default; - virtual ~BadConversion() noexcept; + virtual ~BadConversion() NOEXCEPT; }; template @@ -211,7 +219,7 @@ class YAML_CPP_API BadDereference : public RepresentationException { BadDereference() : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_DEREFERENCE) {} BadDereference(const BadDereference&) = default; - virtual ~BadDereference() noexcept; + virtual ~BadDereference() NOEXCEPT; }; class YAML_CPP_API BadSubscript : public RepresentationException { @@ -219,7 +227,7 @@ class YAML_CPP_API BadSubscript : public RepresentationException { BadSubscript() : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_SUBSCRIPT) {} BadSubscript(const BadSubscript&) = default; - virtual ~BadSubscript() noexcept; + virtual ~BadSubscript() NOEXCEPT; }; class YAML_CPP_API BadPushback : public RepresentationException { @@ -227,7 +235,7 @@ class YAML_CPP_API BadPushback : public RepresentationException { BadPushback() : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_PUSHBACK) {} BadPushback(const BadPushback&) = default; - virtual ~BadPushback() noexcept; + virtual ~BadPushback() NOEXCEPT; }; class YAML_CPP_API BadInsert : public RepresentationException { @@ -235,7 +243,7 @@ class YAML_CPP_API BadInsert : public RepresentationException { BadInsert() : RepresentationException(Mark::null_mark(), ErrorMsg::BAD_INSERT) {} BadInsert(const BadInsert&) = default; - virtual ~BadInsert() noexcept; + virtual ~BadInsert() NOEXCEPT; }; class YAML_CPP_API EmitterException : public Exception { @@ -243,14 +251,14 @@ class YAML_CPP_API EmitterException : public Exception { EmitterException(const std::string& msg_) : Exception(Mark::null_mark(), msg_) {} EmitterException(const EmitterException&) = default; - virtual ~EmitterException() noexcept; + virtual ~EmitterException() NOEXCEPT; }; class YAML_CPP_API BadFile : public Exception { public: BadFile() : Exception(Mark::null_mark(), ErrorMsg::BAD_FILE) {} BadFile(const BadFile&) = default; - virtual ~BadFile() noexcept; + virtual ~BadFile() NOEXCEPT; }; } diff --git a/src/exceptions.cpp b/src/exceptions.cpp index 8b5dfa2..6a5ca1e 100644 --- a/src/exceptions.cpp +++ b/src/exceptions.cpp @@ -3,17 +3,17 @@ namespace YAML { // These destructors are defined out-of-line so the vtable is only emitted once. -Exception::~Exception() noexcept {} -ParserException::~ParserException() noexcept {} -RepresentationException::~RepresentationException() noexcept {} -InvalidScalar::~InvalidScalar() noexcept {} -KeyNotFound::~KeyNotFound() noexcept {} -InvalidNode::~InvalidNode() noexcept {} -BadConversion::~BadConversion() noexcept {} -BadDereference::~BadDereference() noexcept {} -BadSubscript::~BadSubscript() noexcept {} -BadPushback::~BadPushback() noexcept {} -BadInsert::~BadInsert() noexcept {} -EmitterException::~EmitterException() noexcept {} -BadFile::~BadFile() noexcept {} +Exception::~Exception() NOEXCEPT {} +ParserException::~ParserException() NOEXCEPT {} +RepresentationException::~RepresentationException() NOEXCEPT {} +InvalidScalar::~InvalidScalar() NOEXCEPT {} +KeyNotFound::~KeyNotFound() NOEXCEPT {} +InvalidNode::~InvalidNode() NOEXCEPT {} +BadConversion::~BadConversion() NOEXCEPT {} +BadDereference::~BadDereference() NOEXCEPT {} +BadSubscript::~BadSubscript() NOEXCEPT {} +BadPushback::~BadPushback() NOEXCEPT {} +BadInsert::~BadInsert() NOEXCEPT {} +EmitterException::~EmitterException() NOEXCEPT {} +BadFile::~BadFile() NOEXCEPT {} } From da807adc9997beff52fc99e1174289ad8d201653 Mon Sep 17 00:00:00 2001 From: g Date: Tue, 28 Mar 2017 11:52:49 -0700 Subject: [PATCH 2/2] Added condition to check if _NOEXCEPT is defined --- include/yaml-cpp/exceptions.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/include/yaml-cpp/exceptions.h b/include/yaml-cpp/exceptions.h index a2dccaf..7bfd0a1 100644 --- a/include/yaml-cpp/exceptions.h +++ b/include/yaml-cpp/exceptions.h @@ -8,12 +8,16 @@ #endif #ifndef NOEXCEPT -#ifndef _MSC_VER -#define NOEXCEPT noexcept -#else +#ifdef _MSC_VER +#ifdef _NOEXCEPT #define NOEXCEPT _NOEXCEPT -#endif -#endif +#else +#define NOEXCEPT +#endif // ifdef _NOEXCEPT +#else +#define NOEXCEPT noexcept +#endif // ifdef _MSC_VER +#endif // ifdef NOEXCEPT #include "yaml-cpp/mark.h" #include "yaml-cpp/traits.h"