0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Merge pull request #27 from TyRoXx/wpedantic

enabled -Wpedantic and fixed all the warnings
This commit is contained in:
Roland Bock 2015-02-07 14:41:43 +01:00
commit ea57c55b0d
10 changed files with 97 additions and 94 deletions

View File

@ -36,6 +36,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}")
endif () endif ()
set(CMAKE_CXX_FLAGS "-Wconversion -Wpedantic ${CMAKE_CXX_FLAGS}")
set(include_dir "${PROJECT_SOURCE_DIR}/include") set(include_dir "${PROJECT_SOURCE_DIR}/include")
file(GLOB_RECURSE sqlpp_headers "${include_dir}/*.h") file(GLOB_RECURSE sqlpp_headers "${include_dir}/*.h")

View File

@ -34,7 +34,7 @@
#include "MockDb.h" #include "MockDb.h"
#include <sqlpp11/sqlpp11.h> #include <sqlpp11/sqlpp11.h>
SQLPP_ALIAS_PROVIDER(cheesecake); SQLPP_ALIAS_PROVIDER(cheesecake)
MockDb db; MockDb db;
@ -107,7 +107,7 @@ int main()
.from(p.join(x).on(p.feature == x.feature)) .from(p.join(x).on(p.feature == x.feature))
.where(true))) .where(true)))
{ {
int id = row.id; int64_t id = row.id;
std::string name = row.name; std::string name = row.name;
} }
#endif #endif

View File

@ -62,33 +62,33 @@ namespace sqlpp
namespace alias namespace alias
{ {
SQLPP_ALIAS_PROVIDER(a); SQLPP_ALIAS_PROVIDER(a)
SQLPP_ALIAS_PROVIDER(b); SQLPP_ALIAS_PROVIDER(b)
SQLPP_ALIAS_PROVIDER(c); SQLPP_ALIAS_PROVIDER(c)
SQLPP_ALIAS_PROVIDER(d); SQLPP_ALIAS_PROVIDER(d)
SQLPP_ALIAS_PROVIDER(e); SQLPP_ALIAS_PROVIDER(e)
SQLPP_ALIAS_PROVIDER(f); SQLPP_ALIAS_PROVIDER(f)
SQLPP_ALIAS_PROVIDER(g); SQLPP_ALIAS_PROVIDER(g)
SQLPP_ALIAS_PROVIDER(h); SQLPP_ALIAS_PROVIDER(h)
SQLPP_ALIAS_PROVIDER(i); SQLPP_ALIAS_PROVIDER(i)
SQLPP_ALIAS_PROVIDER(j); SQLPP_ALIAS_PROVIDER(j)
SQLPP_ALIAS_PROVIDER(k); SQLPP_ALIAS_PROVIDER(k)
SQLPP_ALIAS_PROVIDER(l); SQLPP_ALIAS_PROVIDER(l)
SQLPP_ALIAS_PROVIDER(m); SQLPP_ALIAS_PROVIDER(m)
SQLPP_ALIAS_PROVIDER(n); SQLPP_ALIAS_PROVIDER(n)
SQLPP_ALIAS_PROVIDER(o); SQLPP_ALIAS_PROVIDER(o)
SQLPP_ALIAS_PROVIDER(p); SQLPP_ALIAS_PROVIDER(p)
SQLPP_ALIAS_PROVIDER(q); SQLPP_ALIAS_PROVIDER(q)
SQLPP_ALIAS_PROVIDER(s); SQLPP_ALIAS_PROVIDER(s)
SQLPP_ALIAS_PROVIDER(t); SQLPP_ALIAS_PROVIDER(t)
SQLPP_ALIAS_PROVIDER(u); SQLPP_ALIAS_PROVIDER(u)
SQLPP_ALIAS_PROVIDER(v); SQLPP_ALIAS_PROVIDER(v)
SQLPP_ALIAS_PROVIDER(w); SQLPP_ALIAS_PROVIDER(w)
SQLPP_ALIAS_PROVIDER(x); SQLPP_ALIAS_PROVIDER(x)
SQLPP_ALIAS_PROVIDER(y); SQLPP_ALIAS_PROVIDER(y)
SQLPP_ALIAS_PROVIDER(z); SQLPP_ALIAS_PROVIDER(z)
SQLPP_ALIAS_PROVIDER(left); SQLPP_ALIAS_PROVIDER(left)
SQLPP_ALIAS_PROVIDER(right); SQLPP_ALIAS_PROVIDER(right)
} }
} }

View File

@ -37,20 +37,20 @@ namespace sqlpp
typename Target::_data_t pick_arg_impl(Statement statement, Term term, const std::true_type&) typename Target::_data_t pick_arg_impl(Statement statement, Term term, const std::true_type&)
{ {
return term; return term;
}; }
template<typename Target, typename Statement, typename Term> template<typename Target, typename Statement, typename Term>
typename Target::_data_t pick_arg_impl(Statement statement, Term term, const std::false_type&) typename Target::_data_t pick_arg_impl(Statement statement, Term term, const std::false_type&)
{ {
return Target::_get_member(statement)._data; return Target::_get_member(statement)._data;
}; }
// Returns a statement's term either by picking the term from the statement or using the new term // Returns a statement's term either by picking the term from the statement or using the new term
template<typename Target, typename Statement, typename Term> template<typename Target, typename Statement, typename Term>
typename Target::_data_t pick_arg(Statement statement, Term term) typename Target::_data_t pick_arg(Statement statement, Term term)
{ {
return pick_arg_impl<Target>(statement, term, std::is_same<typename Target::_data_t, Term>()); return pick_arg_impl<Target>(statement, term, std::is_same<typename Target::_data_t, Term>());
}; }
} }
} }

View File

@ -55,7 +55,9 @@ namespace sqlpp
// See also: "http://stackoverflow.com/questions/6245735/pretty-print-stdtuple/6245777#6245777" // See also: "http://stackoverflow.com/questions/6245735/pretty-print-stdtuple/6245777#6245777"
// Beware of gcc-bug: "http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51253", otherwise an empty swallow struct could be used // Beware of gcc-bug: "http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51253", otherwise an empty swallow struct could be used
using swallow = int[]; using swallow = int[];
(void) swallow{(interpret_tuple_element(std::get<Is>(t), separator, context, Is), 0)...}; (void) swallow{
0, //workaround against -Wpedantic GCC warning "zero-size array 'int [0]'"
(interpret_tuple_element(std::get<Is>(t), separator, context, Is), 0)...};
return context; return context;
} }

View File

@ -90,7 +90,7 @@ namespace sqlpp
transaction_t<Db> start_transaction(Db& db, bool report_unfinished_transaction = report_auto_rollback) transaction_t<Db> start_transaction(Db& db, bool report_unfinished_transaction = report_auto_rollback)
{ {
return { db, report_unfinished_transaction }; return { db, report_unfinished_transaction };
}; }
} }
#endif #endif

View File

@ -36,7 +36,7 @@ namespace sqlpp
{ {
struct can_be_null{}; struct can_be_null{};
struct contains_aggregate_function{}; struct contains_aggregate_function{};
}; }
namespace detail namespace detail
{ {
@ -71,7 +71,7 @@ namespace sqlpp
namespace tag namespace tag
{ {
struct is_expression{}; struct is_expression{};
}; }
namespace detail namespace detail
{ {
template<typename T, typename Enable = void> template<typename T, typename Enable = void>
@ -89,7 +89,7 @@ namespace sqlpp
namespace tag\ namespace tag\
{\ {\
struct name{};\ struct name{};\
};\ }\
namespace detail\ namespace detail\
{\ {\
template<typename T, typename Enable = void>\ template<typename T, typename Enable = void>\
@ -100,65 +100,65 @@ namespace sqlpp
template<typename T>\ template<typename T>\
using name##_t = typename detail::name##_impl<T>::type; using name##_t = typename detail::name##_impl<T>::type;
SQLPP_VALUE_TRAIT_GENERATOR(is_value_type); SQLPP_VALUE_TRAIT_GENERATOR(is_value_type)
SQLPP_VALUE_TRAIT_GENERATOR(is_sql_null); SQLPP_VALUE_TRAIT_GENERATOR(is_sql_null)
SQLPP_VALUE_TRAIT_GENERATOR(is_boolean); SQLPP_VALUE_TRAIT_GENERATOR(is_boolean)
SQLPP_VALUE_TRAIT_GENERATOR(is_integral); SQLPP_VALUE_TRAIT_GENERATOR(is_integral)
SQLPP_VALUE_TRAIT_GENERATOR(is_floating_point); SQLPP_VALUE_TRAIT_GENERATOR(is_floating_point)
template<typename T> template<typename T>
using is_numeric_t = detail::any_t< using is_numeric_t = detail::any_t<
detail::is_element_of<tag::is_integral, typename T::_traits::_tags>::value, detail::is_element_of<tag::is_integral, typename T::_traits::_tags>::value,
detail::is_element_of<tag::is_floating_point, typename T::_traits::_tags>::value>; detail::is_element_of<tag::is_floating_point, typename T::_traits::_tags>::value>;
SQLPP_VALUE_TRAIT_GENERATOR(is_text); SQLPP_VALUE_TRAIT_GENERATOR(is_text)
SQLPP_VALUE_TRAIT_GENERATOR(is_wrapped_value); SQLPP_VALUE_TRAIT_GENERATOR(is_wrapped_value)
SQLPP_VALUE_TRAIT_GENERATOR(is_selectable); SQLPP_VALUE_TRAIT_GENERATOR(is_selectable)
SQLPP_VALUE_TRAIT_GENERATOR(is_multi_expression); SQLPP_VALUE_TRAIT_GENERATOR(is_multi_expression)
SQLPP_VALUE_TRAIT_GENERATOR(is_alias); SQLPP_VALUE_TRAIT_GENERATOR(is_alias)
SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag); SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag)
SQLPP_VALUE_TRAIT_GENERATOR(is_result_field); SQLPP_VALUE_TRAIT_GENERATOR(is_result_field)
SQLPP_VALUE_TRAIT_GENERATOR(must_not_insert); SQLPP_VALUE_TRAIT_GENERATOR(must_not_insert)
SQLPP_VALUE_TRAIT_GENERATOR(must_not_update); SQLPP_VALUE_TRAIT_GENERATOR(must_not_update)
SQLPP_VALUE_TRAIT_GENERATOR(require_insert); SQLPP_VALUE_TRAIT_GENERATOR(require_insert)
SQLPP_VALUE_TRAIT_GENERATOR(trivial_value_is_null); SQLPP_VALUE_TRAIT_GENERATOR(trivial_value_is_null)
SQLPP_VALUE_TRAIT_GENERATOR(null_is_trivial_value); SQLPP_VALUE_TRAIT_GENERATOR(null_is_trivial_value)
SQLPP_VALUE_TRAIT_GENERATOR(is_noop); SQLPP_VALUE_TRAIT_GENERATOR(is_noop)
SQLPP_VALUE_TRAIT_GENERATOR(is_missing); SQLPP_VALUE_TRAIT_GENERATOR(is_missing)
SQLPP_VALUE_TRAIT_GENERATOR(is_return_value); SQLPP_VALUE_TRAIT_GENERATOR(is_return_value)
SQLPP_VALUE_TRAIT_GENERATOR(is_table); SQLPP_VALUE_TRAIT_GENERATOR(is_table)
SQLPP_VALUE_TRAIT_GENERATOR(is_join); SQLPP_VALUE_TRAIT_GENERATOR(is_join)
SQLPP_VALUE_TRAIT_GENERATOR(is_pseudo_table); SQLPP_VALUE_TRAIT_GENERATOR(is_pseudo_table)
SQLPP_VALUE_TRAIT_GENERATOR(is_column); SQLPP_VALUE_TRAIT_GENERATOR(is_column)
SQLPP_VALUE_TRAIT_GENERATOR(is_select); SQLPP_VALUE_TRAIT_GENERATOR(is_select)
SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag_list); SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag_list)
SQLPP_VALUE_TRAIT_GENERATOR(is_select_column_list); SQLPP_VALUE_TRAIT_GENERATOR(is_select_column_list)
SQLPP_VALUE_TRAIT_GENERATOR(is_from); SQLPP_VALUE_TRAIT_GENERATOR(is_from)
SQLPP_VALUE_TRAIT_GENERATOR(is_single_table); SQLPP_VALUE_TRAIT_GENERATOR(is_single_table)
SQLPP_VALUE_TRAIT_GENERATOR(is_into); SQLPP_VALUE_TRAIT_GENERATOR(is_into)
SQLPP_VALUE_TRAIT_GENERATOR(is_extra_tables); SQLPP_VALUE_TRAIT_GENERATOR(is_extra_tables)
SQLPP_VALUE_TRAIT_GENERATOR(is_on); SQLPP_VALUE_TRAIT_GENERATOR(is_on)
SQLPP_VALUE_TRAIT_GENERATOR(is_where); SQLPP_VALUE_TRAIT_GENERATOR(is_where)
SQLPP_VALUE_TRAIT_GENERATOR(is_group_by); SQLPP_VALUE_TRAIT_GENERATOR(is_group_by)
SQLPP_VALUE_TRAIT_GENERATOR(is_having); SQLPP_VALUE_TRAIT_GENERATOR(is_having)
SQLPP_VALUE_TRAIT_GENERATOR(is_order_by); SQLPP_VALUE_TRAIT_GENERATOR(is_order_by)
SQLPP_VALUE_TRAIT_GENERATOR(is_limit); SQLPP_VALUE_TRAIT_GENERATOR(is_limit)
SQLPP_VALUE_TRAIT_GENERATOR(is_offset); SQLPP_VALUE_TRAIT_GENERATOR(is_offset)
SQLPP_VALUE_TRAIT_GENERATOR(is_using_); SQLPP_VALUE_TRAIT_GENERATOR(is_using_)
SQLPP_VALUE_TRAIT_GENERATOR(is_column_list); SQLPP_VALUE_TRAIT_GENERATOR(is_column_list)
SQLPP_VALUE_TRAIT_GENERATOR(is_multi_column); SQLPP_VALUE_TRAIT_GENERATOR(is_multi_column)
SQLPP_VALUE_TRAIT_GENERATOR(is_value_list); SQLPP_VALUE_TRAIT_GENERATOR(is_value_list)
SQLPP_VALUE_TRAIT_GENERATOR(is_assignment); SQLPP_VALUE_TRAIT_GENERATOR(is_assignment)
SQLPP_VALUE_TRAIT_GENERATOR(is_update_list); SQLPP_VALUE_TRAIT_GENERATOR(is_update_list)
SQLPP_VALUE_TRAIT_GENERATOR(is_insert_list); SQLPP_VALUE_TRAIT_GENERATOR(is_insert_list)
SQLPP_VALUE_TRAIT_GENERATOR(is_insert_value); SQLPP_VALUE_TRAIT_GENERATOR(is_insert_value)
SQLPP_VALUE_TRAIT_GENERATOR(is_insert_value_list); SQLPP_VALUE_TRAIT_GENERATOR(is_insert_value_list)
SQLPP_VALUE_TRAIT_GENERATOR(is_sort_order); SQLPP_VALUE_TRAIT_GENERATOR(is_sort_order)
SQLPP_VALUE_TRAIT_GENERATOR(is_parameter); SQLPP_VALUE_TRAIT_GENERATOR(is_parameter)
SQLPP_VALUE_TRAIT_GENERATOR(requires_braces); SQLPP_VALUE_TRAIT_GENERATOR(requires_braces)
SQLPP_VALUE_TRAIT_GENERATOR(enforce_null_result_treatment); SQLPP_VALUE_TRAIT_GENERATOR(enforce_null_result_treatment)
template<typename Tag, bool Condition> template<typename Tag, bool Condition>
using tag_if = typename std::conditional<Condition, Tag, void>::type; using tag_if = typename std::conditional<Condition, Tag, void>::type;

View File

@ -33,7 +33,7 @@
#include <iostream> #include <iostream>
MockDb db = {}; MockDb db = {};
SQLPP_ALIAS_PROVIDER(kaesekuchen); SQLPP_ALIAS_PROVIDER(kaesekuchen)
int main() int main()
{ {

View File

@ -102,7 +102,7 @@ struct MockDbT: public sqlpp::connection
void next(ResultRow& result_row) void next(ResultRow& result_row)
{ {
result_row._invalidate(); result_row._invalidate();
}; }
}; };
// Directly executed statements start here // Directly executed statements start here

View File

@ -38,10 +38,10 @@ MockDb::_serializer_context_t printer;
namespace alias namespace alias
{ {
SQLPP_ALIAS_PROVIDER(a); SQLPP_ALIAS_PROVIDER(a)
SQLPP_ALIAS_PROVIDER(b); SQLPP_ALIAS_PROVIDER(b)
SQLPP_ALIAS_PROVIDER(left); SQLPP_ALIAS_PROVIDER(left)
SQLPP_ALIAS_PROVIDER(right); SQLPP_ALIAS_PROVIDER(right)
} }
int main() int main()