Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Addressed warnings found with Visual C++ and warning-level 4
Browse files Browse the repository at this point in the history
  • Loading branch information
trueqbit committed May 10, 2022
1 parent 84eb267 commit 7a43484
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 48 deletions.
2 changes: 1 addition & 1 deletion dev/ast_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ namespace sqlite_orm {
using node_type = into_t<T>;

template<class L>
void operator()(const node_type& node, L& lambda) const {
void operator()(const node_type& /*node*/, L& /*lambda*/) const {
//..
}
};
Expand Down
14 changes: 7 additions & 7 deletions dev/statement_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ namespace sqlite_orm {
using statement_type = autoincrement_t;

template<class Ctx>
std::string operator()(const statement_type& c, const Ctx&) const {
std::string operator()(const statement_type&, const Ctx&) const {
return "AUTOINCREMENT";
}
};
Expand Down Expand Up @@ -1201,7 +1201,7 @@ namespace sqlite_orm {
using statement_type = into_t<T>;

template<class Ctx>
std::string operator()(const statement_type& statement, const Ctx& context) const {
std::string operator()(const statement_type&, const Ctx& context) const {
auto& tImpl = pick_impl<T>(context.impl);

std::stringstream ss;
Expand Down Expand Up @@ -1447,7 +1447,7 @@ namespace sqlite_orm {
using statement_type = conflict_action;

template<class Ctx>
std::string operator()(const statement_type& statement, const Ctx& context) const {
std::string operator()(const statement_type& statement, const Ctx&) const {
switch(statement) {
case conflict_action::replace:
return "REPLACE";
Expand Down Expand Up @@ -1603,7 +1603,7 @@ namespace sqlite_orm {
using statement_type = from_t<Args...>;

template<class Ctx>
std::string operator()(const statement_type& statement, const Ctx& context) const {
std::string operator()(const statement_type&, const Ctx& context) const {
using tuple = std::tuple<Args...>;

std::stringstream ss;
Expand Down Expand Up @@ -1681,7 +1681,7 @@ namespace sqlite_orm {
using statement_type = trigger_timing;

template<class Ctx>
std::string operator()(const statement_type& statement, const Ctx& context) const {
std::string operator()(const statement_type& statement, const Ctx&) const {
switch(statement) {
case trigger_timing::trigger_before:
return "BEFORE";
Expand All @@ -1699,7 +1699,7 @@ namespace sqlite_orm {
using statement_type = trigger_type;

template<class Ctx>
std::string operator()(const statement_type& statement, const Ctx& context) const {
std::string operator()(const statement_type& statement, const Ctx&) const {
switch(statement) {
case trigger_type::trigger_delete:
return "DELETE";
Expand Down Expand Up @@ -2017,7 +2017,7 @@ namespace sqlite_orm {
using statement_type = default_values_t;

template<class Ctx>
std::string operator()(const statement_type& statement, const Ctx& context) const {
std::string operator()(const statement_type&, const Ctx&) const {
return "DEFAULT VALUES";
}
};
Expand Down
7 changes: 1 addition & 6 deletions dev/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,7 @@ namespace sqlite_orm {
void add_generated_cols(std::vector<const table_xinfo*>& columnsToAdd,
const std::vector<table_xinfo>& storageTableInfo) {
// iterate through storage columns
for(size_t storageColumnInfoIndex = 0; storageColumnInfoIndex < storageTableInfo.size();
++storageColumnInfoIndex) {

// get storage's column info
auto& storageColumnInfo = storageTableInfo[storageColumnInfoIndex];
auto& columnName = storageColumnInfo.name;
for(const table_xinfo& storageColumnInfo: storageTableInfo) {
if(storageColumnInfo.hidden) {
columnsToAdd.push_back(&storageColumnInfo);
}
Expand Down
2 changes: 1 addition & 1 deletion dev/storage_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ namespace sqlite_orm {
return (int*)(new F());
},
/* step = */
[](sqlite3_context* context, void* functionVoidPointer, int argsCount, sqlite3_value** values) {
[](sqlite3_context*, void* functionVoidPointer, int argsCount, sqlite3_value** values) {
auto& functionPointer = *static_cast<F*>(functionVoidPointer);
args_tuple argsTuple;
using tuple_size = std::tuple_size<args_tuple>;
Expand Down
2 changes: 1 addition & 1 deletion dev/typed_comparator.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace sqlite_orm {
namespace internal {

template<class L, class R>
bool compare_any(const L& lhs, const R& rhs) {
bool compare_any(const L& /*lhs*/, const R& /*rhs*/) {
return false;
}
template<class O>
Expand Down
2 changes: 1 addition & 1 deletion dev/values_to_tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace sqlite_orm {

template<class T>
struct values_to_tuple<T, size_t(-1)> {
void extract(sqlite3_value **values, T &tuple, int argsCount) const {
void extract(sqlite3_value ** /*values*/, T & /*tuple*/, int /*argsCount*/) const {
//..
}
};
Expand Down
29 changes: 12 additions & 17 deletions include/sqlite_orm/sqlite_orm.h
Original file line number Diff line number Diff line change
Expand Up @@ -6136,7 +6136,7 @@ namespace sqlite_orm {
namespace internal {

template<class L, class R>
bool compare_any(const L& lhs, const R& rhs) {
bool compare_any(const L& /*lhs*/, const R& /*rhs*/) {
return false;
}
template<class O>
Expand Down Expand Up @@ -11797,7 +11797,7 @@ namespace sqlite_orm {
using node_type = into_t<T>;

template<class L>
void operator()(const node_type& node, L& lambda) const {
void operator()(const node_type& /*node*/, L& /*lambda*/) const {
//..
}
};
Expand Down Expand Up @@ -13424,7 +13424,7 @@ namespace sqlite_orm {

template<class T>
struct values_to_tuple<T, size_t(-1)> {
void extract(sqlite3_value** values, T& tuple, int argsCount) const {
void extract(sqlite3_value** /*values*/, T& /*tuple*/, int /*argsCount*/) const {
//..
}
};
Expand Down Expand Up @@ -13711,7 +13711,7 @@ namespace sqlite_orm {
return (int*)(new F());
},
/* step = */
[](sqlite3_context* context, void* functionVoidPointer, int argsCount, sqlite3_value** values) {
[](sqlite3_context*, void* functionVoidPointer, int argsCount, sqlite3_value** values) {
auto& functionPointer = *static_cast<F*>(functionVoidPointer);
args_tuple argsTuple;
using tuple_size = std::tuple_size<args_tuple>;
Expand Down Expand Up @@ -15458,7 +15458,7 @@ namespace sqlite_orm {
using statement_type = autoincrement_t;

template<class Ctx>
std::string operator()(const statement_type& c, const Ctx&) const {
std::string operator()(const statement_type&, const Ctx&) const {
return "AUTOINCREMENT";
}
};
Expand Down Expand Up @@ -15879,7 +15879,7 @@ namespace sqlite_orm {
using statement_type = into_t<T>;

template<class Ctx>
std::string operator()(const statement_type& statement, const Ctx& context) const {
std::string operator()(const statement_type&, const Ctx& context) const {
auto& tImpl = pick_impl<T>(context.impl);

std::stringstream ss;
Expand Down Expand Up @@ -16125,7 +16125,7 @@ namespace sqlite_orm {
using statement_type = conflict_action;

template<class Ctx>
std::string operator()(const statement_type& statement, const Ctx& context) const {
std::string operator()(const statement_type& statement, const Ctx&) const {
switch(statement) {
case conflict_action::replace:
return "REPLACE";
Expand Down Expand Up @@ -16281,7 +16281,7 @@ namespace sqlite_orm {
using statement_type = from_t<Args...>;

template<class Ctx>
std::string operator()(const statement_type& statement, const Ctx& context) const {
std::string operator()(const statement_type&, const Ctx& context) const {
using tuple = std::tuple<Args...>;

std::stringstream ss;
Expand Down Expand Up @@ -16359,7 +16359,7 @@ namespace sqlite_orm {
using statement_type = trigger_timing;

template<class Ctx>
std::string operator()(const statement_type& statement, const Ctx& context) const {
std::string operator()(const statement_type& statement, const Ctx&) const {
switch(statement) {
case trigger_timing::trigger_before:
return "BEFORE";
Expand All @@ -16377,7 +16377,7 @@ namespace sqlite_orm {
using statement_type = trigger_type;

template<class Ctx>
std::string operator()(const statement_type& statement, const Ctx& context) const {
std::string operator()(const statement_type& statement, const Ctx&) const {
switch(statement) {
case trigger_type::trigger_delete:
return "DELETE";
Expand Down Expand Up @@ -16695,7 +16695,7 @@ namespace sqlite_orm {
using statement_type = default_values_t;

template<class Ctx>
std::string operator()(const statement_type& statement, const Ctx& context) const {
std::string operator()(const statement_type&, const Ctx&) const {
return "DEFAULT VALUES";
}
};
Expand Down Expand Up @@ -16862,12 +16862,7 @@ namespace sqlite_orm {
void add_generated_cols(std::vector<const table_xinfo*>& columnsToAdd,
const std::vector<table_xinfo>& storageTableInfo) {
// iterate through storage columns
for(size_t storageColumnInfoIndex = 0; storageColumnInfoIndex < storageTableInfo.size();
++storageColumnInfoIndex) {

// get storage's column info
auto& storageColumnInfo = storageTableInfo[storageColumnInfoIndex];
auto& columnName = storageColumnInfo.name;
for(const table_xinfo& storageColumnInfo: storageTableInfo) {
if(storageColumnInfo.hidden) {
columnsToAdd.push_back(&storageColumnInfo);
}
Expand Down
14 changes: 13 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,25 @@ if(SQLITE_ORM_OMITS_CODECVT)
endif()

if (MSVC)
target_compile_options(unit_tests PUBLIC /MP) # multi-processor compilation
target_compile_options(unit_tests PUBLIC
# multi-processor compilation
/MP)
if (MSVC_VERSION LESS_EQUAL 1900)
target_compile_options(unit_tests PUBLIC
# C4503: decorated name length exceeded
/wd"4503"
# C4800: forcing value to bool (performance warning)
/wd"4800")
else()
target_compile_options(unit_tests PUBLIC
# warning-level 4
/W4
# C4127: conditional expression is constant
/wd"4127"
# C4456: declaration of 'symbol' hides previous local declaration
/wd"4456")
# C4458: declaration of 'symbol' hides class member
/wd"4458")
endif()
endif()

Expand Down
12 changes: 6 additions & 6 deletions tests/statement_serializer_tests/bindables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ TEST_CASE("bindables") {
#endif
>;

constexpr Tuple t = make_default_tuple<Tuple>();
constexpr Tuple tpl = make_default_tuple<Tuple>();

array<string, tuple_size<Tuple>::value> e{"0",
"0",
Expand Down Expand Up @@ -184,11 +184,11 @@ TEST_CASE("bindables") {

SECTION("dump") {
context.replace_bindable_with_question = false;
test_tuple(t, context, e);
test_tuple(tpl, context, e);
}
SECTION("parametrized") {
context.replace_bindable_with_question = true;
test_tuple(t, context, single_value_array<tuple_size<Tuple>::value>("?"));
test_tuple(tpl, context, single_value_array<tuple_size<Tuple>::value>("?"));
}
SECTION("non-bindable literals") {
context.replace_bindable_with_question = true;
Expand Down Expand Up @@ -220,7 +220,7 @@ TEST_CASE("bindables") {
Custom,
unique_ptr<Custom>>;

Tuple t = make_default_tuple<Tuple>();
Tuple tpl = make_default_tuple<Tuple>();

array<string, tuple_size<Tuple>::value> e{"''",
#ifndef SQLITE_ORM_OMITS_CODECVT
Expand All @@ -246,11 +246,11 @@ TEST_CASE("bindables") {

SECTION("dump") {
context.replace_bindable_with_question = false;
test_tuple(t, context, e);
test_tuple(tpl, context, e);
}
SECTION("parametrized") {
context.replace_bindable_with_question = true;
test_tuple(t, context, single_value_array<tuple_size<Tuple>::value>("?"));
test_tuple(tpl, context, single_value_array<tuple_size<Tuple>::value>("?"));
}
SECTION("non-bindable literals") {
context.replace_bindable_with_question = true;
Expand Down
2 changes: 1 addition & 1 deletion tests/static_tests/column_result_t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using namespace sqlite_orm;

template<class St, class E, class V>
void runTest(V /*value*/) {
using Type = typename internal::column_result_t<St, V>::type;
using Type = internal::column_result_of_t<St, V>;
STATIC_REQUIRE(std::is_same<Type, E>::value);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/storage_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ TEST_CASE("has_dependent_rows") {

#ifndef SQLITE_ORM_AGGREGATE_NSDMI_SUPPORTED
Visit() = default;
Visit(int id, int userId, time_t time) : id{id}, userId{userId}, date{date} {}
Visit(int id, int userId, int date) : id{id}, userId{userId}, date{date} {}
#endif
};
auto storage =
Expand Down
2 changes: 1 addition & 1 deletion tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ TEST_CASE("Custom collate") {
};

struct AlwaysEqualCollation {
int operator()(int leftLength, const void* lhs, int rightLength, const void* rhs) const {
int operator()(int /*leftLength*/, const void* /*lhs*/, int /*rightLength*/, const void* /*rhs*/) const {
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/tests2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,14 +722,14 @@ TEST_CASE("obtain_xdestroy_for") {

#if __cpp_constexpr >= 201603L // constexpr lambda
// [](void* p){}
constexpr auto lambda4_1 = [](void *p) {};
constexpr auto lambda4_1 = [](void *) {};
constexpr xdestroy_fn_t xDestroy4_1 = obtain_xdestroy_for(lambda4_1, int_nullptr);
STATIC_REQUIRE(xDestroy4_1 == lambda4_1);
REQUIRE(xDestroy4_1 == lambda4_1);
#else
#if !defined(_MSC_VER) || (_MSC_VER >= 1914) // conversion of lambda closure to function pointer using `+`
// [](void* p){}
auto lambda4_1 = [](void *p) {};
auto lambda4_1 = [](void *) {};
xdestroy_fn_t xDestroy4_1 = obtain_xdestroy_for(lambda4_1, int_nullptr);
REQUIRE(xDestroy4_1 == lambda4_1);
#endif
Expand Down
4 changes: 2 additions & 2 deletions tests/unique_cases/issue937.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ TEST_CASE("issue937") {
where(c(std::make_tuple(&Employee::m_ename, &Employee::m_job, &Employee::m_salary))
.in(select(columns(&Employee::m_ename, &Employee::m_job, &Employee::m_salary),
where(c(&Employee::m_job) == "Clerk")))));
auto statement = storage.prepare(expression);
REQUIRE_NOTHROW(storage.prepare(expression));
}
{ // issue969
auto expression = select(
Expand All @@ -82,7 +82,7 @@ TEST_CASE("issue937") {
intersect(select(columns(&Employee::m_ename, &Employee::m_job, &Employee::m_salary)),
select(columns(&Employee::m_ename, &Employee::m_job, &Employee::m_salary),
where(c(&Employee::m_job) == "Clerk"))))));
auto statement = storage.prepare(expression);
REQUIRE_NOTHROW(storage.prepare(expression));
}
}
#endif

0 comments on commit 7a43484

Please sign in to comment.