Disable C4702: unreachable code warnings within relevant headers

This commit is contained in:
Tristan Penman 2021-07-28 16:58:15 +10:00
parent 4897d102bd
commit 855365bce0
2 changed files with 37 additions and 28 deletions

View File

@ -26,6 +26,11 @@
#include <valijson/schema.hpp> #include <valijson/schema.hpp>
#include <valijson/exceptions.hpp> #include <valijson/exceptions.hpp>
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4702 )
#endif
namespace valijson { namespace valijson {
class ValidationResults; class ValidationResults;
@ -1236,3 +1241,7 @@ public:
} // namespace constraints } // namespace constraints
} // namespace valijson } // namespace valijson
#ifdef _MSC_VER
#pragma warning( pop )
#endif

View File

@ -13,6 +13,11 @@
#include <valijson/utils/utf8_utils.hpp> #include <valijson/utils/utf8_utils.hpp>
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4702 )
#endif
namespace valijson { namespace valijson {
class ValidationResults; class ValidationResults;
@ -39,7 +44,7 @@ public:
* recording error descriptions. If this pointer is set * recording error descriptions. If this pointer is set
* to nullptr, validation errors will caused validation to * to nullptr, validation errors will caused validation to
* stop immediately. * stop immediately.
* @param regexesCache Cache of already created std::regex objects for pattern * @param regexesCache Cache of already created std::regex objects for pattern
* constraints. * constraints.
*/ */
ValidationVisitor(const AdapterType &target, ValidationVisitor(const AdapterType &target,
@ -1152,37 +1157,28 @@ public:
bool validated = true; bool validated = true;
#ifdef VALIJSON_USE_EXCEPTIONS const typename AdapterType::Array targetArray = m_target.asArray();
try const typename AdapterType::Array::const_iterator end = targetArray.end();
#endif const typename AdapterType::Array::const_iterator secondLast = --targetArray.end();
{ unsigned int outerIndex = 0;
const typename AdapterType::Array targetArray = m_target.asArray(); typename AdapterType::Array::const_iterator outerItr = targetArray.begin();
const typename AdapterType::Array::const_iterator end = targetArray.end(); for (; outerItr != secondLast; ++outerItr) {
const typename AdapterType::Array::const_iterator secondLast = --targetArray.end(); unsigned int innerIndex = outerIndex + 1;
unsigned int outerIndex = 0; typename AdapterType::Array::const_iterator innerItr(outerItr);
typename AdapterType::Array::const_iterator outerItr = targetArray.begin(); for (++innerItr; innerItr != end; ++innerItr) {
for (; outerItr != secondLast; ++outerItr) { if (outerItr->equalTo(*innerItr, true)) {
unsigned int innerIndex = outerIndex + 1; if (!m_results) {
typename AdapterType::Array::const_iterator innerItr(outerItr); return false;
for (++innerItr; innerItr != end; ++innerItr) {
if (outerItr->equalTo(*innerItr, true)) {
if (!m_results) {
return false;
}
m_results->pushError(m_context, "Elements at indexes #" + std::to_string(outerIndex)
+ " and #" + std::to_string(innerIndex) + " violate uniqueness constraint.");
validated = false;
} }
++innerIndex; m_results->pushError(m_context, "Elements at indexes #" + std::to_string(outerIndex)
+ " and #" + std::to_string(innerIndex) + " violate uniqueness constraint.");
validated = false;
} }
++outerIndex; ++innerIndex;
} }
++outerIndex;
} }
#ifdef VALIJSON_USE_EXCEPTIONS
catch (...) {
throw;
}
#endif
return validated; return validated;
} }
@ -1790,3 +1786,7 @@ private:
}; };
} // namespace valijson } // namespace valijson
#ifdef _MSC_VER
#pragma warning( pop )
#endif