Enable warnings (and fix up some things)
This commit is contained in:
@@ -152,7 +152,13 @@ if(MSVC)
|
||||
# how to workaround or fix the error. So I'm disabling it globally.
|
||||
add_definitions(/wd4503)
|
||||
else()
|
||||
add_definitions(-Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -pedantic ${CPP11_FLAG})
|
||||
add_definitions(-Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wcast-qual -Woverloaded-virtual -pedantic ${CPP11_FLAG})
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
add_definitions(-Weverything -Wno-c++98-compat -Wno-documentation -Wno-switch-enum -Wno-weak-vtables)
|
||||
else()
|
||||
add_definitions(-Wnoexcept)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
add_definitions(-Wno-sign-compare)
|
||||
|
@@ -26,6 +26,8 @@ namespace chaiscript {
|
||||
{
|
||||
}
|
||||
|
||||
bad_any_cast(const bad_any_cast &) = default;
|
||||
|
||||
virtual ~bad_any_cast() CHAISCRIPT_NOEXCEPT {}
|
||||
|
||||
/// \brief Description of what error occurred
|
||||
@@ -105,7 +107,7 @@ namespace chaiscript {
|
||||
}
|
||||
}
|
||||
|
||||
#if _MSC_VER != 1800
|
||||
#if !defined(_MSC_VER) || _MSC_VER != 1800
|
||||
Any(Any &&) = default;
|
||||
Any &operator=(Any &&t_any) = default;
|
||||
#endif
|
||||
|
@@ -340,6 +340,13 @@ namespace chaiscript
|
||||
validate_boxed_number(bv);
|
||||
}
|
||||
|
||||
Boxed_Number(const Boxed_Number &) = default;
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER != 1800
|
||||
Boxed_Number(Boxed_Number &&) = default;
|
||||
Boxed_Number& operator=(Boxed_Number &&) = default;
|
||||
#endif
|
||||
|
||||
template<typename T> explicit Boxed_Number(T t)
|
||||
: bv(Boxed_Value(t))
|
||||
{
|
||||
|
@@ -62,6 +62,8 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
reserved_word_error(const reserved_word_error &) = default;
|
||||
|
||||
virtual ~reserved_word_error() CHAISCRIPT_NOEXCEPT {}
|
||||
|
||||
std::string word() const
|
||||
@@ -82,6 +84,8 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
illegal_name_error(const illegal_name_error &) = default;
|
||||
|
||||
virtual ~illegal_name_error() CHAISCRIPT_NOEXCEPT {}
|
||||
|
||||
std::string name() const
|
||||
@@ -103,6 +107,8 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
name_conflict_error(const name_conflict_error &) = default;
|
||||
|
||||
virtual ~name_conflict_error() CHAISCRIPT_NOEXCEPT {}
|
||||
|
||||
std::string name() const
|
||||
@@ -125,6 +131,7 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
global_non_const(const global_non_const &) = default;
|
||||
virtual ~global_non_const() CHAISCRIPT_NOEXCEPT {}
|
||||
};
|
||||
}
|
||||
@@ -389,6 +396,8 @@ namespace chaiscript
|
||||
std::set<std::string> m_reserved_words;
|
||||
|
||||
State &operator=(const State &) = default;
|
||||
State() = default;
|
||||
State(const State &) = default;
|
||||
};
|
||||
|
||||
Dispatch_Engine()
|
||||
|
@@ -197,6 +197,8 @@ namespace chaiscript
|
||||
: std::runtime_error("Guard evaluation failed")
|
||||
{ }
|
||||
|
||||
guard_error(const guard_error &) = default;
|
||||
|
||||
virtual ~guard_error() CHAISCRIPT_NOEXCEPT
|
||||
{ }
|
||||
};
|
||||
|
@@ -42,6 +42,8 @@ namespace chaiscript
|
||||
{
|
||||
}
|
||||
|
||||
arity_error(const arity_error &) = default;
|
||||
|
||||
virtual ~arity_error() CHAISCRIPT_NOEXCEPT {}
|
||||
|
||||
int got;
|
||||
@@ -72,7 +74,7 @@ namespace chaiscript
|
||||
template<typename Param, typename ... Rest>
|
||||
struct Try_Cast<Param, Rest...>
|
||||
{
|
||||
static void do_try(const std::vector<Boxed_Value> ¶ms, int generation, const Type_Conversions &t_conversions)
|
||||
static void do_try(const std::vector<Boxed_Value> ¶ms, size_t generation, const Type_Conversions &t_conversions)
|
||||
{
|
||||
boxed_cast<Param>(params[generation], &t_conversions);
|
||||
Try_Cast<Rest...>::do_try(params, generation+1, t_conversions);
|
||||
@@ -83,7 +85,7 @@ namespace chaiscript
|
||||
template<>
|
||||
struct Try_Cast<>
|
||||
{
|
||||
static void do_try(const std::vector<Boxed_Value> &, int, const Type_Conversions &)
|
||||
static void do_try(const std::vector<Boxed_Value> &, size_t, const Type_Conversions &)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@@ -112,6 +112,8 @@ namespace chaiscript
|
||||
reason(t_why)
|
||||
{}
|
||||
|
||||
eval_error(const eval_error &) = default;
|
||||
|
||||
std::string pretty_print() const
|
||||
{
|
||||
std::ostringstream ss;
|
||||
|
@@ -1333,29 +1333,28 @@ namespace chaiscript
|
||||
|
||||
AST_NodePtr guardnode;
|
||||
|
||||
auto d = t_ss.get_parent_locals();
|
||||
auto itr = d.find("_current_class_name");
|
||||
int class_offset = 0;
|
||||
if (itr != d.end()) class_offset = -1;
|
||||
const auto d = t_ss.get_parent_locals();
|
||||
const auto itr = d.find("_current_class_name");
|
||||
const auto class_offset = (itr != d.end())?-1:0;
|
||||
const std::string & class_name = (itr != d.end())?std::string(boxed_cast<std::string>(itr->second)):this->children[0]->text;
|
||||
|
||||
//The first param of a method is always the implied this ptr.
|
||||
std::vector<std::string> t_param_names{"this"};
|
||||
|
||||
if ((this->children.size() > static_cast<size_t>(3 + class_offset)) && (this->children[(2 + class_offset)]->identifier == AST_Node_Type::Arg_List)) {
|
||||
for (const auto &child : this->children[(2 + class_offset)]->children) {
|
||||
if ((this->children.size() > static_cast<size_t>(3 + class_offset)) && (this->children[static_cast<size_t>(2 + class_offset)]->identifier == AST_Node_Type::Arg_List)) {
|
||||
for (const auto &child : this->children[static_cast<size_t>(2 + class_offset)]->children) {
|
||||
t_param_names.push_back(child->text);
|
||||
}
|
||||
|
||||
if (this->children.size() > static_cast<size_t>(4 + class_offset)) {
|
||||
guardnode = this->children[(3 + class_offset)];
|
||||
guardnode = this->children[static_cast<size_t>(3 + class_offset)];
|
||||
}
|
||||
}
|
||||
else {
|
||||
//no parameters
|
||||
|
||||
if (this->children.size() > static_cast<size_t>(3 + class_offset)) {
|
||||
guardnode = this->children[(2 + class_offset)];
|
||||
guardnode = this->children[static_cast<size_t>(2 + class_offset)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1372,7 +1371,7 @@ namespace chaiscript
|
||||
try {
|
||||
const std::string & l_annotation = this->annotation?this->annotation->text:"";
|
||||
|
||||
const std::string & function_name = this->children[(1 + class_offset)]->text;
|
||||
const std::string & function_name = this->children[static_cast<size_t>(1 + class_offset)]->text;
|
||||
|
||||
if (function_name == class_name) {
|
||||
t_ss.add(std::make_shared<dispatch::detail::Dynamic_Object_Constructor>(class_name, std::make_shared<dispatch::Dynamic_Proxy_Function>(std::bind(chaiscript::eval::detail::eval_function,
|
||||
@@ -1420,24 +1419,23 @@ namespace chaiscript
|
||||
{
|
||||
const auto &d = t_ss.get_parent_locals();
|
||||
const auto itr = d.find("_current_class_name");
|
||||
int class_offset = 0;
|
||||
if (itr != d.end()) class_offset = -1;
|
||||
const auto class_offset = (itr != d.end())?-1:0;
|
||||
std::string class_name = (itr != d.end())?std::string(boxed_cast<std::string>(itr->second)):this->children[0]->text;
|
||||
|
||||
try {
|
||||
t_ss.add(
|
||||
std::make_shared<dispatch::detail::Dynamic_Object_Function>(
|
||||
class_name,
|
||||
std::move(class_name),
|
||||
fun(std::function<Boxed_Value (dispatch::Dynamic_Object &)>(std::bind(&dispatch::Dynamic_Object::get_attr,
|
||||
std::placeholders::_1,
|
||||
this->children[(1 + class_offset)]->text
|
||||
this->children[static_cast<size_t>(1 + class_offset)]->text
|
||||
))
|
||||
)
|
||||
), this->children[(1 + class_offset)]->text);
|
||||
), this->children[static_cast<size_t>(1 + class_offset)]->text);
|
||||
|
||||
}
|
||||
catch (const exception::reserved_word_error &) {
|
||||
throw exception::eval_error("Reserved word used as attribute '" + this->children[(1 + class_offset)]->text + "'");
|
||||
throw exception::eval_error("Reserved word used as attribute '" + this->children[static_cast<size_t>(1 + class_offset)]->text + "'");
|
||||
} catch (const exception::name_conflict_error &e) {
|
||||
throw exception::eval_error("Attribute redefined '" + e.name() + "'");
|
||||
}
|
||||
|
Reference in New Issue
Block a user