diff --git a/include/chaiscript/dispatchkit/exception_specification.hpp b/include/chaiscript/dispatchkit/exception_specification.hpp index 10c3826..c0a6e3c 100644 --- a/include/chaiscript/dispatchkit/exception_specification.hpp +++ b/include/chaiscript/dispatchkit/exception_specification.hpp @@ -17,6 +17,8 @@ namespace chaiscript { virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) = 0; + virtual ~Exception_Handler_Base() {} + protected: template void throw_type(const Boxed_Value &bv, const Dispatch_Engine &t_engine) @@ -28,6 +30,8 @@ namespace chaiscript template struct Exception_Handler_Impl1 : Exception_Handler_Base { + virtual ~Exception_Handler_Impl1() {} + virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) { throw_type(bv, t_engine); @@ -36,6 +40,8 @@ namespace chaiscript template struct Exception_Handler_Impl2 : Exception_Handler_Base { + virtual ~Exception_Handler_Impl2() {} + virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) { throw_type(bv, t_engine); @@ -46,6 +52,8 @@ namespace chaiscript template struct Exception_Handler_Impl3 : Exception_Handler_Base { + virtual ~Exception_Handler_Impl3() {} + virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) { throw_type(bv, t_engine); @@ -56,6 +64,8 @@ namespace chaiscript template struct Exception_Handler_Impl4 : Exception_Handler_Base { + virtual ~Exception_Handler_Impl4() {} + virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) { throw_type(bv, t_engine); @@ -67,6 +77,8 @@ namespace chaiscript template struct Exception_Handler_Impl5 : Exception_Handler_Base { + virtual ~Exception_Handler_Impl5() {} + virtual void handle(const Boxed_Value &bv, const Dispatch_Engine &t_engine) { throw_type(bv, t_engine); diff --git a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp index f114726..5260ec1 100644 --- a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp @@ -88,7 +88,7 @@ namespace chaiscript template bool compare_types_cast(Ret (*)(Params...), const std::vector ¶ms, const Dynamic_Cast_Conversions &t_conversions) - { + { try { Try_Cast::do_try(params, 0, t_conversions); } catch (const exception::bad_boxed_cast &) { diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index 581e8ed..d3fefc6 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -483,19 +483,20 @@ namespace chaiscript try { const std::string appendedpath = m_usepaths[i] + t_filename; - chaiscript::detail::threading::lock_guard l(m_use_mutex); - chaiscript::detail::threading::shared_lock l2(m_mutex); + chaiscript::detail::threading::unique_lock l(m_use_mutex); + chaiscript::detail::threading::unique_lock l2(m_mutex); if (m_used_files.count(appendedpath) == 0) { - m_used_files.insert(appendedpath); l2.unlock(); eval_file(appendedpath); - } + l2.lock(); + m_used_files.insert(appendedpath); + } return; // return, we loaded it, or it was already loaded } catch (const exception::file_not_found_error &) { - if (i == m_usepaths.size() - 1) + if (i == m_usepaths.size() - 1) { throw exception::file_not_found_error(t_filename); } diff --git a/src/reflection.cpp b/src/reflection.cpp index 40e9efe..b7cb1c5 100644 --- a/src/reflection.cpp +++ b/src/reflection.cpp @@ -44,6 +44,12 @@ chaiscript::AST_NodePtr get_parse_tree(const chaiscript::Const_Proxy_Function &t } +#ifdef __llvm__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreturn-type-c-linkage" +#endif + + CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_reflection() { chaiscript::ModulePtr m(new chaiscript::Module()); @@ -98,6 +104,11 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_reflect return m; } +#ifdef __llvm__ +#pragma clang diagnostic pop +#endif + + #ifdef CHAISCRIPT_MSVC #pragma warning(pop) diff --git a/src/stl_extra.cpp b/src/stl_extra.cpp index 9868366..e97dfb3 100644 --- a/src/stl_extra.cpp +++ b/src/stl_extra.cpp @@ -11,11 +11,19 @@ #pragma warning(disable : 4190) #endif +#ifdef __llvm__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreturn-type-c-linkage" +#endif + CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_stl_extra() { return chaiscript::bootstrap::standard_library::list_type >("List"); } +#ifdef __llvm__ +#pragma clang diagnostic pop +#endif #ifdef CHAISCRIPT_MSVC #pragma warning(pop) diff --git a/src/test_module.cpp b/src/test_module.cpp index 3e2f21e..5b1aa0a 100644 --- a/src/test_module.cpp +++ b/src/test_module.cpp @@ -49,6 +49,10 @@ int *get_new_int() #pragma warning(disable : 4190) #endif +#ifdef __llvm__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreturn-type-c-linkage" +#endif CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test_module() { @@ -86,6 +90,10 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test_mo } +#ifdef __llvm__ +#pragma clang diagnostic pop +#endif + #ifdef CHAISCRIPT_MSVC #pragma warning(pop) #endif diff --git a/unittests/multithreaded_test.cpp b/unittests/multithreaded_test.cpp index 806dfb6..3b8c862 100644 --- a/unittests/multithreaded_test.cpp +++ b/unittests/multithreaded_test.cpp @@ -24,13 +24,17 @@ int expected_value(int num_iters) void do_work(chaiscript::ChaiScript &c, int id) { - std::stringstream ss; - ss << "MyVar" << rand(); - c.add(chaiscript::var(5), ss.str()); - ss.str(""); - ss << id; - c.use("multithreaded_work.inc"); - c("do_chai_work(4000, " + ss.str() + ");"); + try{ + std::stringstream ss; + ss << "MyVar" << rand(); + c.add(chaiscript::var(5), ss.str()); + ss.str(""); + ss << id; + c.use("multithreaded_work.inc"); + c("do_chai_work(4000, " + ss.str() + ");"); + } catch (const std::exception &e) { + std::cout << "exception: " << e.what() << " thread: " << id; + } } int main() @@ -80,6 +84,7 @@ int main() } + for (int i = 0; i < num_threads; ++i) { std::stringstream ss;