From 3cef1a12179b84e35811c4d854cb32a14cdf3d84 Mon Sep 17 00:00:00 2001 From: TyRoXx Date: Wed, 4 Feb 2015 21:43:10 +0100 Subject: [PATCH] enable -Wpedantic and fix all the warnings Conflicts: examples/select.cpp include/sqlpp11/interpret_tuple.h include/sqlpp11/type_traits.h --- CMakeLists.txt | 2 +- examples/select.cpp | 2 +- include/sqlpp11/alias_provider.h | 54 +++++++------- include/sqlpp11/detail/pick_arg.h | 6 +- include/sqlpp11/interpret_tuple.h | 4 +- include/sqlpp11/transaction.h | 2 +- include/sqlpp11/type_traits.h | 119 +++++++++++++++--------------- include/sqlpp11/with.h | 2 +- tests/FunctionTest.cpp | 2 +- tests/MockDb.h | 2 +- tests/SelectTypeTest.cpp | 8 +- 11 files changed, 103 insertions(+), 100 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ded9a29d..69ca76f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}") endif () -set(CMAKE_CXX_FLAGS "-Wconversion ${CMAKE_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS "-Wconversion -Wpedantic ${CMAKE_CXX_FLAGS}") set(include_dir "${PROJECT_SOURCE_DIR}/include") file(GLOB_RECURSE sqlpp_headers "${include_dir}/*.h") diff --git a/examples/select.cpp b/examples/select.cpp index 9c3a767f..790fd96b 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -37,7 +37,7 @@ static constexpr bool some_condition = true; static constexpr bool some_other_condition = false; -SQLPP_ALIAS_PROVIDER(cheesecake); +SQLPP_ALIAS_PROVIDER(cheesecake) MockDb db; diff --git a/include/sqlpp11/alias_provider.h b/include/sqlpp11/alias_provider.h index ba07cf9f..57d501ca 100644 --- a/include/sqlpp11/alias_provider.h +++ b/include/sqlpp11/alias_provider.h @@ -64,33 +64,33 @@ namespace sqlpp inline namespace alias { - SQLPP_ALIAS_PROVIDER(a); - SQLPP_ALIAS_PROVIDER(b); - SQLPP_ALIAS_PROVIDER(c); - SQLPP_ALIAS_PROVIDER(d); - SQLPP_ALIAS_PROVIDER(e); - SQLPP_ALIAS_PROVIDER(f); - SQLPP_ALIAS_PROVIDER(g); - SQLPP_ALIAS_PROVIDER(h); - SQLPP_ALIAS_PROVIDER(i); - SQLPP_ALIAS_PROVIDER(j); - SQLPP_ALIAS_PROVIDER(k); - SQLPP_ALIAS_PROVIDER(l); - SQLPP_ALIAS_PROVIDER(m); - SQLPP_ALIAS_PROVIDER(n); - SQLPP_ALIAS_PROVIDER(o); - SQLPP_ALIAS_PROVIDER(p); - SQLPP_ALIAS_PROVIDER(q); - SQLPP_ALIAS_PROVIDER(s); - SQLPP_ALIAS_PROVIDER(t); - SQLPP_ALIAS_PROVIDER(u); - SQLPP_ALIAS_PROVIDER(v); - SQLPP_ALIAS_PROVIDER(w); - SQLPP_ALIAS_PROVIDER(x); - SQLPP_ALIAS_PROVIDER(y); - SQLPP_ALIAS_PROVIDER(z); - SQLPP_ALIAS_PROVIDER(left); - SQLPP_ALIAS_PROVIDER(right); + SQLPP_ALIAS_PROVIDER(a) + SQLPP_ALIAS_PROVIDER(b) + SQLPP_ALIAS_PROVIDER(c) + SQLPP_ALIAS_PROVIDER(d) + SQLPP_ALIAS_PROVIDER(e) + SQLPP_ALIAS_PROVIDER(f) + SQLPP_ALIAS_PROVIDER(g) + SQLPP_ALIAS_PROVIDER(h) + SQLPP_ALIAS_PROVIDER(i) + SQLPP_ALIAS_PROVIDER(j) + SQLPP_ALIAS_PROVIDER(k) + SQLPP_ALIAS_PROVIDER(l) + SQLPP_ALIAS_PROVIDER(m) + SQLPP_ALIAS_PROVIDER(n) + SQLPP_ALIAS_PROVIDER(o) + SQLPP_ALIAS_PROVIDER(p) + SQLPP_ALIAS_PROVIDER(q) + SQLPP_ALIAS_PROVIDER(s) + SQLPP_ALIAS_PROVIDER(t) + SQLPP_ALIAS_PROVIDER(u) + SQLPP_ALIAS_PROVIDER(v) + SQLPP_ALIAS_PROVIDER(w) + SQLPP_ALIAS_PROVIDER(x) + SQLPP_ALIAS_PROVIDER(y) + SQLPP_ALIAS_PROVIDER(z) + SQLPP_ALIAS_PROVIDER(left) + SQLPP_ALIAS_PROVIDER(right) } } diff --git a/include/sqlpp11/detail/pick_arg.h b/include/sqlpp11/detail/pick_arg.h index 10cd512b..6c922516 100644 --- a/include/sqlpp11/detail/pick_arg.h +++ b/include/sqlpp11/detail/pick_arg.h @@ -37,20 +37,20 @@ namespace sqlpp typename Target::_data_t pick_arg_impl(Statement statement, Term term, const std::true_type&) { return term; - }; + } template typename Target::_data_t pick_arg_impl(Statement statement, Term term, const std::false_type&) { return Target::_get_member(statement)._data; - }; + } // Returns a statement's term either by picking the term from the statement or using the new term template typename Target::_data_t pick_arg(Statement statement, Term term) { return pick_arg_impl(statement, term, std::is_same()); - }; + } } } diff --git a/include/sqlpp11/interpret_tuple.h b/include/sqlpp11/interpret_tuple.h index 36c047b7..a51a8288 100644 --- a/include/sqlpp11/interpret_tuple.h +++ b/include/sqlpp11/interpret_tuple.h @@ -54,7 +54,9 @@ namespace sqlpp // 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 using swallow = int[]; - (void) swallow{(interpret_tuple_element(std::get(t), separator, context, useBraces, Is), 0)...}; + (void) swallow{ + 0, //workaround against -Wpedantic GCC warning "zero-size array 'int [0]'" + (interpret_tuple_element(std::get(t), separator, context, useBraces, Is), 0)...}; return context; } diff --git a/include/sqlpp11/transaction.h b/include/sqlpp11/transaction.h index b0d456cc..c140d168 100644 --- a/include/sqlpp11/transaction.h +++ b/include/sqlpp11/transaction.h @@ -90,7 +90,7 @@ namespace sqlpp transaction_t start_transaction(Db& db, bool report_unfinished_transaction = report_auto_rollback) { return { db, report_unfinished_transaction }; - }; + } } #endif diff --git a/include/sqlpp11/type_traits.h b/include/sqlpp11/type_traits.h index e1f0239c..8dee9b18 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -39,7 +39,7 @@ namespace sqlpp { struct can_be_null{}; struct contains_aggregate_function{}; - }; + } namespace detail { @@ -74,7 +74,7 @@ namespace sqlpp namespace tag { struct is_expression{}; - }; + } namespace detail { template @@ -92,7 +92,7 @@ namespace sqlpp namespace tag\ {\ struct name{};\ - };\ + }\ namespace detail\ {\ template\ @@ -103,70 +103,71 @@ namespace sqlpp template\ using name##_t = typename detail::name##_impl::type; - SQLPP_VALUE_TRAIT_GENERATOR(is_value_type); - SQLPP_VALUE_TRAIT_GENERATOR(is_sql_null); - SQLPP_VALUE_TRAIT_GENERATOR(is_boolean); - SQLPP_VALUE_TRAIT_GENERATOR(is_integral); - SQLPP_VALUE_TRAIT_GENERATOR(is_floating_point); + SQLPP_VALUE_TRAIT_GENERATOR(is_value_type) + SQLPP_VALUE_TRAIT_GENERATOR(is_sql_null) + SQLPP_VALUE_TRAIT_GENERATOR(is_boolean) + SQLPP_VALUE_TRAIT_GENERATOR(is_integral) + SQLPP_VALUE_TRAIT_GENERATOR(is_floating_point) template using is_numeric_t = logic::any_t< detail::is_element_of::value, detail::is_element_of::value>; - SQLPP_VALUE_TRAIT_GENERATOR(is_text); - SQLPP_VALUE_TRAIT_GENERATOR(is_wrapped_value); - SQLPP_VALUE_TRAIT_GENERATOR(is_selectable); - SQLPP_VALUE_TRAIT_GENERATOR(is_multi_expression); - SQLPP_VALUE_TRAIT_GENERATOR(is_alias); - SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag); - SQLPP_VALUE_TRAIT_GENERATOR(is_result_field); - SQLPP_VALUE_TRAIT_GENERATOR(must_not_insert); - SQLPP_VALUE_TRAIT_GENERATOR(must_not_update); - SQLPP_VALUE_TRAIT_GENERATOR(require_insert); - SQLPP_VALUE_TRAIT_GENERATOR(trivial_value_is_null); - SQLPP_VALUE_TRAIT_GENERATOR(null_is_trivial_value); + SQLPP_VALUE_TRAIT_GENERATOR(is_text) + SQLPP_VALUE_TRAIT_GENERATOR(is_wrapped_value) + SQLPP_VALUE_TRAIT_GENERATOR(is_selectable) + SQLPP_VALUE_TRAIT_GENERATOR(is_multi_expression) + SQLPP_VALUE_TRAIT_GENERATOR(is_alias) + SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag) + SQLPP_VALUE_TRAIT_GENERATOR(is_result_field) - SQLPP_VALUE_TRAIT_GENERATOR(is_with); - SQLPP_VALUE_TRAIT_GENERATOR(is_cte); - SQLPP_VALUE_TRAIT_GENERATOR(is_statement); - SQLPP_VALUE_TRAIT_GENERATOR(is_prepared_statement); - SQLPP_VALUE_TRAIT_GENERATOR(is_noop); - SQLPP_VALUE_TRAIT_GENERATOR(is_missing); - SQLPP_VALUE_TRAIT_GENERATOR(is_return_value); - SQLPP_VALUE_TRAIT_GENERATOR(is_table); - SQLPP_VALUE_TRAIT_GENERATOR(is_join); - SQLPP_VALUE_TRAIT_GENERATOR(is_pseudo_table); - SQLPP_VALUE_TRAIT_GENERATOR(is_column); - SQLPP_VALUE_TRAIT_GENERATOR(is_select); - SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_select_column_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_from); - SQLPP_VALUE_TRAIT_GENERATOR(is_single_table); - SQLPP_VALUE_TRAIT_GENERATOR(is_into); - SQLPP_VALUE_TRAIT_GENERATOR(is_extra_tables); - SQLPP_VALUE_TRAIT_GENERATOR(is_on); - SQLPP_VALUE_TRAIT_GENERATOR(is_where); - SQLPP_VALUE_TRAIT_GENERATOR(is_group_by); - SQLPP_VALUE_TRAIT_GENERATOR(is_having); - SQLPP_VALUE_TRAIT_GENERATOR(is_order_by); - SQLPP_VALUE_TRAIT_GENERATOR(is_limit); - SQLPP_VALUE_TRAIT_GENERATOR(is_offset); - SQLPP_VALUE_TRAIT_GENERATOR(is_union); - SQLPP_VALUE_TRAIT_GENERATOR(is_using_); - SQLPP_VALUE_TRAIT_GENERATOR(is_column_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_multi_column); - SQLPP_VALUE_TRAIT_GENERATOR(is_value_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_assignment); - SQLPP_VALUE_TRAIT_GENERATOR(is_update_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_insert_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_insert_value); - SQLPP_VALUE_TRAIT_GENERATOR(is_insert_value_list); - SQLPP_VALUE_TRAIT_GENERATOR(is_sort_order); - SQLPP_VALUE_TRAIT_GENERATOR(is_parameter); + SQLPP_VALUE_TRAIT_GENERATOR(must_not_insert) + SQLPP_VALUE_TRAIT_GENERATOR(must_not_update) + SQLPP_VALUE_TRAIT_GENERATOR(require_insert) + SQLPP_VALUE_TRAIT_GENERATOR(trivial_value_is_null) + SQLPP_VALUE_TRAIT_GENERATOR(null_is_trivial_value) - SQLPP_VALUE_TRAIT_GENERATOR(requires_braces); + SQLPP_VALUE_TRAIT_GENERATOR(is_statement) + SQLPP_VALUE_TRAIT_GENERATOR(is_prepared_statement) + SQLPP_VALUE_TRAIT_GENERATOR(is_union) + SQLPP_VALUE_TRAIT_GENERATOR(is_with) + SQLPP_VALUE_TRAIT_GENERATOR(is_cte) + SQLPP_VALUE_TRAIT_GENERATOR(is_noop) + SQLPP_VALUE_TRAIT_GENERATOR(is_missing) + SQLPP_VALUE_TRAIT_GENERATOR(is_return_value) + SQLPP_VALUE_TRAIT_GENERATOR(is_table) + SQLPP_VALUE_TRAIT_GENERATOR(is_join) + SQLPP_VALUE_TRAIT_GENERATOR(is_pseudo_table) + SQLPP_VALUE_TRAIT_GENERATOR(is_column) + SQLPP_VALUE_TRAIT_GENERATOR(is_select) + SQLPP_VALUE_TRAIT_GENERATOR(is_select_flag_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_select_column_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_from) + SQLPP_VALUE_TRAIT_GENERATOR(is_single_table) + SQLPP_VALUE_TRAIT_GENERATOR(is_into) + SQLPP_VALUE_TRAIT_GENERATOR(is_extra_tables) + SQLPP_VALUE_TRAIT_GENERATOR(is_on) + SQLPP_VALUE_TRAIT_GENERATOR(is_where) + SQLPP_VALUE_TRAIT_GENERATOR(is_group_by) + SQLPP_VALUE_TRAIT_GENERATOR(is_having) + SQLPP_VALUE_TRAIT_GENERATOR(is_order_by) + SQLPP_VALUE_TRAIT_GENERATOR(is_limit) + SQLPP_VALUE_TRAIT_GENERATOR(is_offset) + SQLPP_VALUE_TRAIT_GENERATOR(is_using_) + SQLPP_VALUE_TRAIT_GENERATOR(is_column_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_multi_column) + SQLPP_VALUE_TRAIT_GENERATOR(is_value_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_assignment) + SQLPP_VALUE_TRAIT_GENERATOR(is_update_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_insert_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_insert_value) + SQLPP_VALUE_TRAIT_GENERATOR(is_insert_value_list) + SQLPP_VALUE_TRAIT_GENERATOR(is_sort_order) + SQLPP_VALUE_TRAIT_GENERATOR(is_parameter) - SQLPP_VALUE_TRAIT_GENERATOR(enforce_null_result_treatment); + SQLPP_VALUE_TRAIT_GENERATOR(requires_braces) + + SQLPP_VALUE_TRAIT_GENERATOR(enforce_null_result_treatment) template using tag_if = typename std::conditional::type; diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index 95dd3e68..48a2e5c3 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -93,7 +93,7 @@ namespace sqlpp return t.with; } -#warning: Need real checks here + // FIXME: Need real checks here using _consistency_check = consistent_t; }; }; diff --git a/tests/FunctionTest.cpp b/tests/FunctionTest.cpp index b0026480..bde10db5 100644 --- a/tests/FunctionTest.cpp +++ b/tests/FunctionTest.cpp @@ -33,7 +33,7 @@ #include MockDb db = {}; -SQLPP_ALIAS_PROVIDER(kaesekuchen); +SQLPP_ALIAS_PROVIDER(kaesekuchen) int main() { diff --git a/tests/MockDb.h b/tests/MockDb.h index 567866d2..9ec072a1 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -103,7 +103,7 @@ struct MockDbT: public sqlpp::connection void next(ResultRow& result_row) { result_row._invalidate(); - }; + } }; // Directly executed statements start here diff --git a/tests/SelectTypeTest.cpp b/tests/SelectTypeTest.cpp index bd0e9be8..70f61811 100644 --- a/tests/SelectTypeTest.cpp +++ b/tests/SelectTypeTest.cpp @@ -38,10 +38,10 @@ MockDb::_serializer_context_t printer; namespace alias { - SQLPP_ALIAS_PROVIDER(a); - SQLPP_ALIAS_PROVIDER(b); - SQLPP_ALIAS_PROVIDER(left); - SQLPP_ALIAS_PROVIDER(right); + SQLPP_ALIAS_PROVIDER(a) + SQLPP_ALIAS_PROVIDER(b) + SQLPP_ALIAS_PROVIDER(left) + SQLPP_ALIAS_PROVIDER(right) } int main()