From 5c4de7e43c1f1e2fd3cb3330d75e53998ff0acff Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 24 Apr 2015 14:29:15 -0600 Subject: [PATCH 1/3] More catch() analysis warning cleanups --- .decent_ci-Linux.yaml | 2 +- src/test_module.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.decent_ci-Linux.yaml b/.decent_ci-Linux.yaml index 931e699..6f7125f 100644 --- a/.decent_ci-Linux.yaml +++ b/.decent_ci-Linux.yaml @@ -26,5 +26,5 @@ compilers: skip_packaging: true cmake_extra_flags: -DBUILD_SAMPLES:BOOL=ON -DBUILD_PACKAGE:BOOL=ON -DBUILD_TESTING:BOOL=ON - name: cppcheck - compiler_extra_flags: --enable=all -I include --inline-suppr -Umax --suppress="*:cmake*" --suppress="*:catch.hpp" --force + compiler_extra_flags: --enable=all -I include --inline-suppr -Umax --suppress="*:cmake*" --suppress="*:unittests/catch.hpp" --force diff --git a/src/test_module.cpp b/src/test_module.cpp index f27faaf..949b01b 100644 --- a/src/test_module.cpp +++ b/src/test_module.cpp @@ -8,9 +8,9 @@ class TestBaseType { public: - TestBaseType() : val(10), const_val(15) { } - TestBaseType(int) : val(10), const_val(15) {} - TestBaseType(int *) : val(10), const_val(15) { } + TestBaseType() : val(10), const_val(15), mdarray{} { } + TestBaseType(int) : val(10), const_val(15), mdarray{} {} + TestBaseType(int *) : val(10), const_val(15), mdarray{} { } TestBaseType(const TestBaseType &) = default; virtual ~TestBaseType() {} virtual int func() { return 0; } From fa16bcd08e970e903b1bb64b5a6a154843f0ae8b Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 24 Apr 2015 16:10:44 -0600 Subject: [PATCH 2/3] More warning management --- src/test_module.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/test_module.cpp b/src/test_module.cpp index 949b01b..1ed7182 100644 --- a/src/test_module.cpp +++ b/src/test_module.cpp @@ -8,9 +8,18 @@ class TestBaseType { public: +#ifdef CHAISCRIPT_MSVC_12 +#pragma warning(push) +#pragma warning(disable : 4351) +#endif + // MSVC 12 warns that we are using new (correct) behavior TestBaseType() : val(10), const_val(15), mdarray{} { } - TestBaseType(int) : val(10), const_val(15), mdarray{} {} - TestBaseType(int *) : val(10), const_val(15), mdarray{} { } + TestBaseType(int) : val(10), const_val(15), mdarray{} { } + TestBaseType(int *) : val(10), const_val(15), mdarray{} { } +#ifdef CHAISCRIPT_MSVC_12 +#pragma warning(pop) +#endif + TestBaseType(const TestBaseType &) = default; virtual ~TestBaseType() {} virtual int func() { return 0; } From 4f5f46a2e53ddf4c26feb19edc82dd356cbbc82d Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 24 Apr 2015 22:36:22 -0600 Subject: [PATCH 3/3] Don't use scopes around arithmetic operators --- .../codeanalysis/heterogenous_array_loop.chai | 19 ++++++++++++++----- .../chaiscript/language/chaiscript_eval.hpp | 8 +++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/contrib/codeanalysis/heterogenous_array_loop.chai b/contrib/codeanalysis/heterogenous_array_loop.chai index 5c688d1..d94d53f 100644 --- a/contrib/codeanalysis/heterogenous_array_loop.chai +++ b/contrib/codeanalysis/heterogenous_array_loop.chai @@ -1,10 +1,19 @@ -var my_array=["1", 4, 6.6l, 10ul, "1000", 100, 10.9f ]; - -for (var j = 0; j < 10000; ++j) +def go() { - for (var i = 0; i < 6; ++i) + var my_array=["1", 4, 6.6l, 10ul, "1000", 100, 10.9f ]; + + var q = 0; + + for (var j = 0; j < 10000; ++j) { - to_string(my_array[i]); + for (var i = 0; i < 6; ++i) + { + to_string(my_array[i]); + } + + q += j; } } + +go(); diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 5b2b495..38c588b 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -90,9 +90,6 @@ namespace chaiscript Operators::Opers t_oper, const std::string &t_oper_string, const Boxed_Value &t_lhs, const Boxed_Value &t_rhs) const { try { - chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); - fpp.save_params({t_lhs, t_rhs}); - if (t_oper != Operators::invalid && t_lhs.get_type_info().is_arithmetic() && t_rhs.get_type_info().is_arithmetic()) { // If it's an arithmetic operation we want to short circuit dispatch @@ -103,8 +100,9 @@ namespace chaiscript } catch (...) { throw exception::eval_error("Error with numeric operator calling: " + t_oper_string); } - } else { + chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); + fpp.save_params({t_lhs, t_rhs}); chaiscript::eval::detail::Stack_Push_Pop spp(t_ss); return t_ss.call_function(t_oper_string, t_lhs, t_rhs); } @@ -1218,7 +1216,6 @@ namespace chaiscript virtual ~Prefix_AST_Node() {} virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss) const CHAISCRIPT_OVERRIDE{ - chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); Boxed_Value bv(this->children[1]->eval(t_ss)); try { @@ -1227,6 +1224,7 @@ namespace chaiscript { return Boxed_Number::do_oper(m_oper, std::move(bv)); } else { + chaiscript::eval::detail::Function_Push_Pop fpp(t_ss); chaiscript::eval::detail::Stack_Push_Pop spp(t_ss); fpp.save_params({bv}); return t_ss.call_function(this->children[0]->text, std::move(bv));