diff --git a/dynare++/tl/cc/equivalence.cc b/dynare++/tl/cc/equivalence.cc index ca0a525abf9a8c2a5b70291c4c3a843494ad2a7c..3c1a392e21679f7bd416b5e24ab8eb348c6d18f3 100644 --- a/dynare++/tl/cc/equivalence.cc +++ b/dynare++/tl/cc/equivalence.cc @@ -384,13 +384,9 @@ EquivalenceBundle::EquivalenceBundle(int nmax) const EquivalenceSet & EquivalenceBundle::get(int n) const { - if (n > static_cast<int>(bundle.size()) || n < 1) - { - TL_RAISE("Equivalence set not found in EquivalenceBundle::get"); - return bundle[0]; - } - else - return bundle[n-1]; + TL_RAISE_IF(n > static_cast<int>(bundle.size()) || n < 1, + "Equivalence set not found in EquivalenceBundle::get"); + return bundle[n-1]; } /* Get |curmax| which is a maximum size in the bundle, and generate for diff --git a/dynare++/tl/cc/ps_tensor.cc b/dynare++/tl/cc/ps_tensor.cc index f9880df02d3b953c18cf6414207cbe8727862485..48acd7cb0af2d9f8ca93cc47fc25c4247de71bea 100644 --- a/dynare++/tl/cc/ps_tensor.cc +++ b/dynare++/tl/cc/ps_tensor.cc @@ -62,7 +62,6 @@ std::unique_ptr<FTensor> UPSTensor::fold() const { TL_RAISE("Never should come to this place in UPSTensor::fold"); - return std::make_unique<FFSTensor>(0, 0, 0); } int @@ -319,7 +318,6 @@ std::unique_ptr<UTensor> FPSTensor::unfold() const { TL_RAISE("Unfolding of FPSTensor not implemented"); - return std::make_unique<UFSTensor>(0, 0, 0); } /* We only call |calcOffset| of the |PerTensorDimens2|. */ diff --git a/dynare++/tl/cc/pyramid_prod2.hh b/dynare++/tl/cc/pyramid_prod2.hh index d8b9e33a0490e9e383f880f0c4dbb8fbc8fde8ff..5e10c3c5b6a63ad65846bc41fb7732914a93a3aa 100644 --- a/dynare++/tl/cc/pyramid_prod2.hh +++ b/dynare++/tl/cc/pyramid_prod2.hh @@ -147,7 +147,7 @@ public: int getOffset(const IntSequence &v) const override { - TL_RAISE("Not implemented error in IrregTensor::getOffset"); return 0; + TL_RAISE("Not implemented error in IrregTensor::getOffset"); } }; diff --git a/dynare++/tl/cc/sparse_tensor.cc b/dynare++/tl/cc/sparse_tensor.cc index 308c88c593a2e098b57ca74379e9299735e54985..b8e50ddf5ae40b0e4e7501f810ea24fb51f756cf 100644 --- a/dynare++/tl/cc/sparse_tensor.cc +++ b/dynare++/tl/cc/sparse_tensor.cc @@ -24,11 +24,7 @@ SparseTensor::insert(const IntSequence &key, int r, double c) // check that pair |key| and |r| is unique auto last_pos = m.upper_bound(key); for (auto it = first_pos; it != last_pos; ++it) - if ((*it).second.first == r) - { - TL_RAISE("Duplicate <key, r> insertion in SparseTensor::insert"); - return; - } + TL_RAISE_IF(it->second.first == r, "Duplicate <key, r> insertion in SparseTensor::insert"); m.insert(first_pos, Map::value_type(key, Item(r, c))); if (first_nz_row > r) diff --git a/dynare++/tl/cc/stack_container.hh b/dynare++/tl/cc/stack_container.hh index 670ac29d5c4720f1e479fa1d1222ad8271629995..6e256defd4ac52312a0093739634de1dcdb43761 100644 --- a/dynare++/tl/cc/stack_container.hh +++ b/dynare++/tl/cc/stack_container.hh @@ -381,7 +381,6 @@ public: return _Stype::zero; TL_RAISE("Wrong stack index in ZContainer::getType"); - return _Stype::zero; } }; @@ -464,7 +463,6 @@ public: return _Stype::zero; TL_RAISE("Wrong stack index in GContainer::getType"); - return _Stype::zero; } }; diff --git a/dynare++/tl/cc/tl_exception.hh b/dynare++/tl/cc/tl_exception.hh index eb14fecb6b22b174d0ff20a134d6b0d6400d7576..300289244e658473c77e4952becbfa355767e31b 100644 --- a/dynare++/tl/cc/tl_exception.hh +++ b/dynare++/tl/cc/tl_exception.hh @@ -24,13 +24,13 @@ the exceptions. If the |TL_DEBUG| is equal or higher than |TL_DEBUG_EXCEPTION|, the exception conditions are checked. - We define |TL_RAISE|, and |TL_RAISE_IF| macros which throw an instance - of |TLException| if |TL_DEBUG >= TL_DEBUG_EXCEPTION|. The first is - unconditional throw, the second is conditioned by a given - expression. Note that if |TL_DEBUG < TL_DEBUG_EXCEPTION| then the code - is compiled but evaluation of the condition is passed. If code is - optimized, the optimizer also passes evaluation of |TL_DEBUG| and - |TL_DEBUG_EXCEPTION| comparison (I hope). + We define |TL_RAISE|, and |TL_RAISE_IF| macros which throw an instance of + |TLException| (only if |TL_DEBUG >= TL_DEBUG_EXCEPTION| for the latter). The + first is unconditional throw, the second is conditioned by a given + expression. Note that if |TL_DEBUG < TL_DEBUG_EXCEPTION| then the code is + compiled but evaluation of the condition is passed. If code is optimized, + the optimizer also passes evaluation of |TL_DEBUG| and |TL_DEBUG_EXCEPTION| + comparison (I hope). We provide default values for |TL_DEBUG| and |TL_DEBUG_EXCEPTION|. */ @@ -43,7 +43,7 @@ #endif #define TL_RAISE(mes) \ - if (TL_DEBUG >= TL_DEBUG_EXCEPTION) throw TLException(__FILE__, __LINE__, mes); + throw TLException(__FILE__, __LINE__, mes) #define TL_RAISE_IF(expr, mes) \ if (TL_DEBUG >= TL_DEBUG_EXCEPTION && (expr)) throw TLException(__FILE__, __LINE__, mes);