Commit 0973ed90 authored by Diego Caballero's avatar Diego Caballero Committed by Scott Cyphers

[WIP] Fix unreachable warnings in constant_folding.cpp (#3146)

* [WIP] Fix unreachable warnings in constant_folding.cpp

* Introduce NGRAPH_UNREACHABLE macro and silent unreachable warnings

* Fix typo and add missing NGRAPH_UNREACHABLE
parent 96343ffb
......@@ -156,3 +156,9 @@ namespace ngraph
/// \throws ::ngraph::CheckFailure if `cond` is false.
#define NGRAPH_CHECK(cond, ...) \
NGRAPH_CHECK_HELPER(::ngraph::CheckFailure, "", (cond), ##__VA_ARGS__)
/// \brief Macro to signal a code path that is unreachable in a successful execution. It's
/// implemented with NGRAPH_CHECK macro.
/// \param ... Additional error message that should describe why that execution path is unreachable.
/// \throws ::ngrap::CheckFailure if the macro is executed.
#define NGRAPH_UNREACHABLE(...) NGRAPH_CHECK(false, "Unreachable: ", ##__VA_ARGS__)
......@@ -845,6 +845,9 @@ shared_ptr<op::Constant> fold_constant_convert_helper0(shared_ptr<op::Constant>
case element::Type_t::u64:
return fold_constant_convert_helper1<TI, uint64_t>(constant, output_element_type);
}
NGRAPH_UNREACHABLE("Unexpected switch case");
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic pop
#endif
......@@ -900,6 +903,9 @@ static shared_ptr<op::Constant> fold_constant_convert(shared_ptr<op::Constant> c
case element::Type_t::u64:
return fold_constant_convert_helper0<uint64_t>(constant, output_element_type);
}
NGRAPH_UNREACHABLE("Unexpected switch case");
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic pop
#endif
......@@ -1021,6 +1027,9 @@ static shared_ptr<op::Constant> fold_constant_reverse(shared_ptr<op::Constant> c
case element::Type_t::u64:
return fold_constant_reverse_helper<uint64_t>(constant, reversed_axes);
}
NGRAPH_UNREACHABLE("Unexpected switch case");
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic pop
#endif
......@@ -1113,6 +1122,9 @@ static shared_ptr<op::Constant> fold_constant_product(shared_ptr<op::Constant> c
case element::Type_t::u64:
return fold_constant_product_helper<uint64_t>(constant, reduction_axes, result_shape);
}
NGRAPH_UNREACHABLE("Unexpected switch case");
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic pop
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment