Clean up more warnings with stricter warning levels
This commit is contained in:
parent
41a45ce8b5
commit
f95ca75aca
@ -155,7 +155,7 @@ else()
|
|||||||
add_definitions(-Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wcast-qual -Woverloaded-virtual -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")
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
add_definitions(-Weverything -Wno-c++98-compat -Wno-documentation -Wno-switch-enum -Wno-weak-vtables)
|
add_definitions(-Weverything -Wno-c++98-compat -Wno-documentation -Wno-switch-enum -Wno-weak-vtables -Wno-sign-conversion -Wno-missing-prototypes -Wno-padded)
|
||||||
else()
|
else()
|
||||||
add_definitions(-Wnoexcept)
|
add_definitions(-Wnoexcept)
|
||||||
endif()
|
endif()
|
||||||
|
@ -45,7 +45,8 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~bad_boxed_cast() CHAISCRIPT_NOEXCEPT {}
|
bad_boxed_cast(const bad_boxed_cast &) = default;
|
||||||
|
virtual ~bad_boxed_cast() CHAISCRIPT_NOEXCEPT = default;
|
||||||
|
|
||||||
/// \brief Description of what error occurred
|
/// \brief Description of what error occurred
|
||||||
virtual const char * what() const CHAISCRIPT_NOEXCEPT CHAISCRIPT_OVERRIDE
|
virtual const char * what() const CHAISCRIPT_NOEXCEPT CHAISCRIPT_OVERRIDE
|
||||||
|
@ -298,7 +298,7 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void throw_exception(const Boxed_Value &bv) {
|
static void throw_exception [[ noreturn ]] (const Boxed_Value &bv) {
|
||||||
throw bv;
|
throw bv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,15 @@ namespace chaiscript
|
|||||||
#pragma warning(disable : 4244 4018 4389 4146 4365)
|
#pragma warning(disable : 4244 4018 4389 4146 4365)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
#pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||||
|
#pragma GCC diagnostic ignored "-Wconversion"
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||||
|
#endif
|
||||||
|
|
||||||
/// \brief Represents any numeric type, generically. Used internally for generic operations between POD values
|
/// \brief Represents any numeric type, generically. Used internally for generic operations between POD values
|
||||||
class Boxed_Number
|
class Boxed_Number
|
||||||
{
|
{
|
||||||
@ -40,9 +49,6 @@ namespace chaiscript
|
|||||||
struct boolean
|
struct boolean
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
|
||||||
#endif
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
static Boxed_Value go(Operators::Opers t_oper, const T &t, const U &u, const Boxed_Value &)
|
static Boxed_Value go(Operators::Opers t_oper, const T &t, const U &u, const Boxed_Value &)
|
||||||
{
|
{
|
||||||
@ -850,14 +856,18 @@ namespace chaiscript
|
|||||||
struct Cast_Helper<const Boxed_Number &> : Cast_Helper<Boxed_Number>
|
struct Cast_Helper<const Boxed_Number &> : Cast_Helper<Boxed_Number>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Cast_Helper for converting from Boxed_Value to Boxed_Number
|
/// Cast_Helper for converting from Boxed_Value to Boxed_Number
|
||||||
template<>
|
template<>
|
||||||
struct Cast_Helper<const Boxed_Number> : Cast_Helper<Boxed_Number>
|
struct Cast_Helper<const Boxed_Number> : Cast_Helper<Boxed_Number>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CHAISCRIPT_MSVC
|
#ifdef CHAISCRIPT_MSVC
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
@ -72,8 +72,8 @@ namespace chaiscript
|
|||||||
chaiscript::detail::Any m_obj;
|
chaiscript::detail::Any m_obj;
|
||||||
void *m_data_ptr;
|
void *m_data_ptr;
|
||||||
const void *m_const_data_ptr;
|
const void *m_const_data_ptr;
|
||||||
bool m_is_ref;
|
|
||||||
std::unique_ptr<std::map<std::string, Boxed_Value>> m_attrs;
|
std::unique_ptr<std::map<std::string, Boxed_Value>> m_attrs;
|
||||||
|
bool m_is_ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Object_Data
|
struct Object_Data
|
||||||
|
@ -129,7 +129,7 @@ namespace chaiscript
|
|||||||
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions &t_conversions) const = 0;
|
virtual Boxed_Value do_call(const std::vector<Boxed_Value> ¶ms, const Type_Conversions &t_conversions) const = 0;
|
||||||
|
|
||||||
Proxy_Function_Base(std::vector<Type_Info> t_types, int t_arity)
|
Proxy_Function_Base(std::vector<Type_Info> t_types, int t_arity)
|
||||||
: m_types(std::move(t_types)), m_has_arithmetic_param(false), m_arity(t_arity)
|
: m_types(std::move(t_types)), m_arity(t_arity), m_has_arithmetic_param(false)
|
||||||
{
|
{
|
||||||
for (size_t i = 1; i < m_types.size(); ++i)
|
for (size_t i = 1; i < m_types.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -175,8 +175,8 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Type_Info> m_types;
|
std::vector<Type_Info> m_types;
|
||||||
bool m_has_arithmetic_param;
|
|
||||||
int m_arity;
|
int m_arity;
|
||||||
|
bool m_has_arithmetic_param;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,11 +220,11 @@ namespace chaiscript
|
|||||||
std::string t_description = "",
|
std::string t_description = "",
|
||||||
Proxy_Function t_guard = Proxy_Function())
|
Proxy_Function t_guard = Proxy_Function())
|
||||||
: Proxy_Function_Base(build_param_type_list(t_arity), t_arity),
|
: Proxy_Function_Base(build_param_type_list(t_arity), t_arity),
|
||||||
m_f(std::move(t_f)), m_arity(t_arity), m_description(std::move(t_description)), m_guard(std::move(t_guard)), m_parsenode(std::move(t_parsenode))
|
m_guard(std::move(t_guard)), m_parsenode(std::move(t_parsenode)), m_description(std::move(t_description)), m_f(std::move(t_f))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Dynamic_Proxy_Function() {}
|
virtual ~Dynamic_Proxy_Function() = default;
|
||||||
|
|
||||||
virtual bool operator==(const Proxy_Function_Base &rhs) const CHAISCRIPT_OVERRIDE
|
virtual bool operator==(const Proxy_Function_Base &rhs) const CHAISCRIPT_OVERRIDE
|
||||||
{
|
{
|
||||||
@ -311,11 +311,10 @@ namespace chaiscript
|
|||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::function<Boxed_Value (const std::vector<Boxed_Value> &)> m_f;
|
|
||||||
int m_arity;
|
|
||||||
std::string m_description;
|
|
||||||
Proxy_Function m_guard;
|
Proxy_Function m_guard;
|
||||||
AST_NodePtr m_parsenode;
|
AST_NodePtr m_parsenode;
|
||||||
|
std::string m_description;
|
||||||
|
std::function<Boxed_Value (const std::vector<Boxed_Value> &)> m_f;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -591,7 +590,8 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~dispatch_error() CHAISCRIPT_NOEXCEPT {}
|
dispatch_error(const dispatch_error &) = default;
|
||||||
|
virtual ~dispatch_error() CHAISCRIPT_NOEXCEPT = default;
|
||||||
|
|
||||||
std::vector<Boxed_Value> parameters;
|
std::vector<Boxed_Value> parameters;
|
||||||
std::vector<Const_Proxy_Function> functions;
|
std::vector<Const_Proxy_Function> functions;
|
||||||
|
@ -44,7 +44,9 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~bad_boxed_dynamic_cast() CHAISCRIPT_NOEXCEPT {}
|
bad_boxed_dynamic_cast(const bad_boxed_dynamic_cast &) = default;
|
||||||
|
|
||||||
|
virtual ~bad_boxed_dynamic_cast() CHAISCRIPT_NOEXCEPT = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class bad_boxed_type_cast : public bad_boxed_cast
|
class bad_boxed_type_cast : public bad_boxed_cast
|
||||||
@ -66,7 +68,9 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~bad_boxed_type_cast() CHAISCRIPT_NOEXCEPT {}
|
bad_boxed_type_cast(const bad_boxed_type_cast &) = default;
|
||||||
|
|
||||||
|
virtual ~bad_boxed_type_cast() CHAISCRIPT_NOEXCEPT = default;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +397,8 @@ namespace chaiscript
|
|||||||
: std::runtime_error("File Not Found: " + t_filename)
|
: std::runtime_error("File Not Found: " + t_filename)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual ~file_not_found_error() CHAISCRIPT_NOEXCEPT {}
|
file_not_found_error(const file_not_found_error &) = default;
|
||||||
|
virtual ~file_not_found_error() CHAISCRIPT_NOEXCEPT = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,8 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~load_module_error() CHAISCRIPT_NOEXCEPT
|
load_module_error(const load_module_error &) = default;
|
||||||
{
|
virtual ~load_module_error() CHAISCRIPT_NOEXCEPT = default;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,8 +223,8 @@ namespace chaiscript
|
|||||||
t_t->end.column = pos_col_stop;
|
t_t->end.column = pos_col_stop;
|
||||||
|
|
||||||
if (is_deep) {
|
if (is_deep) {
|
||||||
t_t->children.assign(m_match_stack.begin() + t_match_start, m_match_stack.end());
|
t_t->children.assign(m_match_stack.begin() + static_cast<int>(t_match_start), m_match_stack.end());
|
||||||
m_match_stack.erase(m_match_stack.begin() + t_match_start, m_match_stack.end());
|
m_match_stack.erase(m_match_stack.begin() + static_cast<int>(t_match_start), m_match_stack.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \todo fix the fact that a successful match that captured no ast_nodes doesn't have any real start position
|
/// \todo fix the fact that a successful match that captured no ast_nodes doesn't have any real start position
|
||||||
@ -1910,6 +1910,7 @@ namespace chaiscript
|
|||||||
case(AST_Node_Type::Bitwise_Xor) :
|
case(AST_Node_Type::Bitwise_Xor) :
|
||||||
case(AST_Node_Type::Bitwise_Or) :
|
case(AST_Node_Type::Bitwise_Or) :
|
||||||
case(AST_Node_Type::Comparison) :
|
case(AST_Node_Type::Comparison) :
|
||||||
|
assert(m_match_stack.size() > 1);
|
||||||
m_match_stack.erase(m_match_stack.begin() + m_match_stack.size() - 2, m_match_stack.begin() + m_match_stack.size() - 1);
|
m_match_stack.erase(m_match_stack.begin() + m_match_stack.size() - 2, m_match_stack.begin() + m_match_stack.size() - 1);
|
||||||
build_match(std::make_shared<eval::Binary_Operator_AST_Node>(oper->text), prev_stack_top);
|
build_match(std::make_shared<eval::Binary_Operator_AST_Node>(oper->text), prev_stack_top);
|
||||||
break;
|
break;
|
||||||
|
28
src/main.cpp
28
src/main.cpp
@ -8,7 +8,10 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <chaiscript/chaiscript.hpp>
|
#include <chaiscript/chaiscript.hpp>
|
||||||
|
|
||||||
#ifdef READLINE_AVAILABLE
|
#ifdef READLINE_AVAILABLE
|
||||||
@ -18,7 +21,7 @@
|
|||||||
|
|
||||||
char *mystrdup (const char *s) {
|
char *mystrdup (const char *s) {
|
||||||
size_t len = strlen(s); // Space for length plus nul
|
size_t len = strlen(s); // Space for length plus nul
|
||||||
char *d = static_cast<char*>(malloc (len+1));
|
char *d = static_cast<char*>(malloc (len+1));
|
||||||
if (d == nullptr) return nullptr; // No memory
|
if (d == nullptr) return nullptr; // No memory
|
||||||
#ifdef CHAISCRIPT_MSVC
|
#ifdef CHAISCRIPT_MSVC
|
||||||
strcpy_s(d, len, s); // Copy the characters
|
strcpy_s(d, len, s); // Copy the characters
|
||||||
@ -152,10 +155,6 @@ void help(int n) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void version(int){
|
|
||||||
std::cout << "chai: compiled " << __TIME__ << " " << __DATE__ << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
bool throws_exception(const std::function<void ()> &f)
|
bool throws_exception(const std::function<void ()> &f)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -214,11 +213,11 @@ std::string get_next_command() {
|
|||||||
|
|
||||||
// We have to wrap exit with our own because Clang has a hard time with
|
// We have to wrap exit with our own because Clang has a hard time with
|
||||||
// function pointers to functions with special attributes (system exit being marked NORETURN)
|
// function pointers to functions with special attributes (system exit being marked NORETURN)
|
||||||
void myexit(int return_val) {
|
void myexit [[ noreturn ]] (int return_val) {
|
||||||
exit(return_val);
|
exit(return_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void interactive(chaiscript::ChaiScript& chai)
|
void interactive [[ noreturn ]] (chaiscript::ChaiScript& chai)
|
||||||
{
|
{
|
||||||
using_history();
|
using_history();
|
||||||
|
|
||||||
@ -287,7 +286,6 @@ int main(int argc, char *argv[])
|
|||||||
chai.add(chaiscript::fun(&myexit), "exit");
|
chai.add(chaiscript::fun(&myexit), "exit");
|
||||||
chai.add(chaiscript::fun(&myexit), "quit");
|
chai.add(chaiscript::fun(&myexit), "quit");
|
||||||
chai.add(chaiscript::fun(&help), "help");
|
chai.add(chaiscript::fun(&help), "help");
|
||||||
chai.add(chaiscript::fun(&version), "version");
|
|
||||||
chai.add(chaiscript::fun(&throws_exception), "throws_exception");
|
chai.add(chaiscript::fun(&throws_exception), "throws_exception");
|
||||||
chai.add(chaiscript::fun(&get_eval_error), "get_eval_error");
|
chai.add(chaiscript::fun(&get_eval_error), "get_eval_error");
|
||||||
|
|
||||||
@ -317,7 +315,7 @@ int main(int argc, char *argv[])
|
|||||||
arg += line + '\n' ;
|
arg += line + '\n' ;
|
||||||
}
|
}
|
||||||
} else if ( arg == "-v" || arg == "--version" ) {
|
} else if ( arg == "-v" || arg == "--version" ) {
|
||||||
arg = "version(0)" ;
|
arg = "version()" ;
|
||||||
} else if ( arg == "-h" || arg == "--help" ) {
|
} else if ( arg == "-h" || arg == "--help" ) {
|
||||||
arg = "help(-1)";
|
arg = "help(-1)";
|
||||||
} else if ( arg == "-i" || arg == "--interactive" ) {
|
} else if ( arg == "-i" || arg == "--interactive" ) {
|
||||||
@ -332,10 +330,14 @@ int main(int argc, char *argv[])
|
|||||||
chaiscript::Boxed_Value val ;
|
chaiscript::Boxed_Value val ;
|
||||||
try {
|
try {
|
||||||
switch ( mode ) {
|
switch ( mode ) {
|
||||||
case eInteractive : interactive(chai); break;
|
case eInteractive:
|
||||||
case eCommand : val = chai.eval(arg); break;
|
// interactive never returns, no need for break;
|
||||||
case eFile : val = chai.eval_file(arg); break;
|
interactive(chai);
|
||||||
default : std::cout << "Unrecognized execution mode\n"; return EXIT_FAILURE;
|
case eCommand:
|
||||||
|
val = chai.eval(arg);
|
||||||
|
break;
|
||||||
|
case eFile:
|
||||||
|
val = chai.eval_file(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const chaiscript::exception::eval_error &ee) {
|
catch (const chaiscript::exception::eval_error &ee) {
|
||||||
|
@ -10,6 +10,7 @@ class TestBaseType
|
|||||||
TestBaseType() : val(10), const_val(15) { }
|
TestBaseType() : val(10), const_val(15) { }
|
||||||
TestBaseType(int) : val(10), const_val(15) {}
|
TestBaseType(int) : val(10), const_val(15) {}
|
||||||
TestBaseType(int *) : val(10), const_val(15) {}
|
TestBaseType(int *) : val(10), const_val(15) {}
|
||||||
|
TestBaseType(const TestBaseType &) = default;
|
||||||
virtual ~TestBaseType() {}
|
virtual ~TestBaseType() {}
|
||||||
virtual int func() { return 0; }
|
virtual int func() { return 0; }
|
||||||
|
|
||||||
@ -62,6 +63,8 @@ class TestDerivedType : public TestBaseType
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~TestDerivedType() {}
|
virtual ~TestDerivedType() {}
|
||||||
|
TestDerivedType(const TestDerivedType &) = default;
|
||||||
|
TestDerivedType() = default;
|
||||||
virtual int func() CHAISCRIPT_OVERRIDE { return 1; }
|
virtual int func() CHAISCRIPT_OVERRIDE { return 1; }
|
||||||
int derived_only_func() { return 19; }
|
int derived_only_func() { return 19; }
|
||||||
|
|
||||||
@ -72,6 +75,8 @@ class TestDerivedType : public TestBaseType
|
|||||||
class TestMoreDerivedType : public TestDerivedType
|
class TestMoreDerivedType : public TestDerivedType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
TestMoreDerivedType(const TestMoreDerivedType &) = default;
|
||||||
|
TestMoreDerivedType() = default;
|
||||||
virtual ~TestMoreDerivedType() {}
|
virtual ~TestMoreDerivedType() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <chaiscript/utility/utility.hpp>
|
#include <chaiscript/utility/utility.hpp>
|
||||||
|
|
||||||
double test_call(const std::function<double (int)> &f, int val)
|
int test_call(const std::function<int (int)> &f, int val)
|
||||||
{
|
{
|
||||||
return f(val);
|
return f(val);
|
||||||
}
|
}
|
||||||
@ -9,15 +9,15 @@ int main()
|
|||||||
{
|
{
|
||||||
|
|
||||||
chaiscript::ChaiScript chai;
|
chaiscript::ChaiScript chai;
|
||||||
|
|
||||||
chai.add(chaiscript::fun(&test_call), "test_call");
|
chai.add(chaiscript::fun(&test_call), "test_call");
|
||||||
|
|
||||||
chai.eval("def func(i) { return i * 3.5; };");
|
chai.eval("def func(i) { return i * 6; };");
|
||||||
double d = chai.eval<double>("test_call(func, 3)");
|
int d = chai.eval<int>("test_call(func, 3)");
|
||||||
|
|
||||||
if (d == 3 * 3.5)
|
if (d == 3 * 6)
|
||||||
{
|
{
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
struct Vector2
|
struct Vector2
|
||||||
{
|
{
|
||||||
Vector2() : x(0), y(0) {};
|
Vector2() : x(0), y(0) {}
|
||||||
Vector2(T px, T py) : x(px), y(py) {};
|
Vector2(T px, T py) : x(px), y(py) {}
|
||||||
Vector2(const Vector2& cp) : x(cp.x), y(cp.y) {};
|
Vector2(const Vector2& cp) : x(cp.x), y(cp.y) {}
|
||||||
|
|
||||||
Vector2& operator+=(const Vector2& vec_r)
|
Vector2& operator+=(const Vector2& vec_r)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user