From a88a146b5d263d459c95095fe1af36c368aafe17 Mon Sep 17 00:00:00 2001 From: TyRoXx Date: Wed, 4 Feb 2015 21:34:46 +0100 Subject: [PATCH 1/3] enable -Wconversion and fix a warning --- CMakeLists.txt | 1 + examples/select.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1116b7f..ded9a29d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +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(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 3bcba136..64551066 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -107,7 +107,7 @@ int main() .from(p.join(x).on(p.feature == x.feature)) .where(true))) { - int id = row.id; + int64_t id = row.id; std::string name = row.name; } #endif From a480ce625954e2a3351de90027d046804b1c6a88 Mon Sep 17 00:00:00 2001 From: TyRoXx Date: Wed, 4 Feb 2015 21:43:10 +0100 Subject: [PATCH 2/3] enable -Wpedantic and fix all the warnings --- 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 | 108 +++++++++++++++--------------- tests/FunctionTest.cpp | 2 +- tests/MockDb.h | 2 +- tests/SelectTypeTest.cpp | 8 +-- 10 files changed, 96 insertions(+), 94 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 64551066..48d33521 100644 --- a/examples/select.cpp +++ b/examples/select.cpp @@ -34,7 +34,7 @@ #include "MockDb.h" #include -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 78dcf1e3..2b1dccda 100644 --- a/include/sqlpp11/alias_provider.h +++ b/include/sqlpp11/alias_provider.h @@ -62,33 +62,33 @@ namespace sqlpp 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 4edb2631..44c61bd8 100644 --- a/include/sqlpp11/interpret_tuple.h +++ b/include/sqlpp11/interpret_tuple.h @@ -55,7 +55,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, Is), 0)...}; + (void) swallow{ + 0, //workaround against -Wpedantic GCC warning "zero-size array 'int [0]'" + (interpret_tuple_element(std::get(t), separator, context, 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 a0714bdc..6160b15c 100644 --- a/include/sqlpp11/type_traits.h +++ b/include/sqlpp11/type_traits.h @@ -36,7 +36,7 @@ namespace sqlpp { struct can_be_null{}; struct contains_aggregate_function{}; - }; + } namespace detail { @@ -71,7 +71,7 @@ namespace sqlpp namespace tag { struct is_expression{}; - }; + } namespace detail { template @@ -89,7 +89,7 @@ namespace sqlpp namespace tag\ {\ struct name{};\ - };\ + }\ namespace detail\ {\ template\ @@ -100,65 +100,65 @@ 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 = detail::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(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(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_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(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(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 using tag_if = typename std::conditional::type; 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 0586c04c..2db57106 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -102,7 +102,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 00c0d882..b59496ee 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() From d0f4c7dad56a01660988ae9d614b45a866519a7f Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 7 Feb 2015 13:31:45 +0100 Subject: [PATCH 3/3] Fixed paths to test executables for ctest --- examples/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1ab2fd65..bc461a0e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -3,7 +3,7 @@ macro (build arg) # Add headers to sources to enable file browsing in IDEs include_directories("${CMAKE_SOURCE_DIR}/tests") add_executable("Sqlpp11Example${arg}" "${arg}.cpp" ${sqlpp_headers} "${CMAKE_SOURCE_DIR}/tests/MockDb.h" "${CMAKE_CURRENT_LIST_DIR}/Sample.h") - add_test("${arg}" "${arg}") + add_test("${arg}" "${CMAKE_BINARY_DIR}/examples/Sqlpp11Example${arg}") endmacro () #build(sample) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 86462e61..022a55ab 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,7 +3,7 @@ macro (build_and_run arg) # Add headers to sources to enable file browsing in IDEs include_directories("${CMAKE_BINARY_DIR}/tests") add_executable("${arg}" "${arg}.cpp" ${sqlpp_headers} "${CMAKE_CURRENT_LIST_DIR}/Sample.h") - add_test("${arg}" "${arg}") + add_test("${arg}" "${CMAKE_BINARY_DIR}/tests/${arg}") endmacro () build_and_run(BooleanExpressionTest)