From ddd2e0a7c99869c51990bf2dba5e7b0a3f5b52c2 Mon Sep 17 00:00:00 2001 From: Anton Perkov Date: Fri, 16 Feb 2018 16:17:01 -0500 Subject: [PATCH] enable almost all compiler warnings on wasm side, disable all warnings from libc, libc++ and boost --- CMakeModules/wasm.cmake | 31 ++++++++++++++++++----- contracts/CMakeLists.txt | 6 ++++- contracts/eosiolib/account.hpp | 8 +++--- contracts/eosiolib/action.h | 4 +-- contracts/eosiolib/datastream.hpp | 4 +-- contracts/eosiolib/eosiolib.cpp | 2 -- contracts/eosiolib/math.h | 4 +-- contracts/eosiolib/multi_index.hpp | 2 +- contracts/eosiolib/print.h | 6 ++--- contracts/eosiolib/print.hpp | 16 ++++++------ contracts/eosiolib/real.hpp | 6 ----- contracts/eosiolib/token.hpp | 2 +- contracts/eosiolib/transaction.h | 4 --- contracts/eosiolib/transaction.hpp | 6 ++--- contracts/eosiolib/types.hpp | 2 +- contracts/eosiolib/varint.hpp | 2 +- contracts/libc++/CMakeLists.txt | 1 + contracts/multi_index_test/CMakeLists.txt | 2 +- contracts/musl/CMakeLists.txt | 1 + contracts/stltest/stltest.cpp | 2 -- contracts/stltest/stltest.hpp | 1 - 21 files changed, 61 insertions(+), 51 deletions(-) delete mode 100644 contracts/stltest/stltest.hpp diff --git a/CMakeModules/wasm.cmake b/CMakeModules/wasm.cmake index 97e782f7c..9b39c4d6a 100644 --- a/CMakeModules/wasm.cmake +++ b/CMakeModules/wasm.cmake @@ -59,7 +59,8 @@ if( NOT ("${WASM_CLANG}" STREQUAL "" OR "${WASM_LLC}" STREQUAL "" OR "${WASM_LLV endif() macro(compile_wast) - cmake_parse_arguments(ARG "" "TARGET" "SOURCE_FILES;INCLUDE_FOLDERS" ${ARGN}) + #read arguments include ones that we don't since arguments get forwared "as is" and we don't want to threat unknown argument names as values + cmake_parse_arguments(ARG "NOWARNINGS" "TARGET;DESTINATION_FOLDER" "SOURCE_FILES;INCLUDE_FOLDERS;SYSTEM_INCLUDE_FOLDERS;LIBRARIES" ${ARGN}) set(target ${ARG_TARGET}) # NOTE: Setting SOURCE_FILE and looping over it to avoid cmake issue with compilation ${target}.bc's rule colliding with @@ -106,10 +107,28 @@ macro(compile_wast) -nostdlib -nostdlibinc -fno-threadsafe-statics -fno-rtti -fno-exceptions -c ${infile} -o ${outfile}.bc ) + if (${ARG_NOWARNINGS}) + list(APPEND WASM_COMMAND -Wno-everything) + else() + list(APPEND WASM_COMMAND -Weverything -Wno-c++98-compat -Wno-old-style-cast -Wno-vla -Wno-vla-extension -Wno-c++98-compat-pedantic + -Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-packed -Wno-sign-compare -Wno-sign-conversion) + endif() + foreach(folder ${ARG_INCLUDE_FOLDERS}) list(APPEND WASM_COMMAND -I ${folder}) endforeach() - + + if ("${ARG_SYSTEM_INCLUDE_FOLDERS}" STREQUAL "") + set (ARG_SYSTEM_INCLUDE_FOLDERS ${DEFAULT_SYSTEM_INCLUDE_FOLDERS}) + endif() + foreach(folder ${ARG_SYSTEM_INCLUDE_FOLDERS}) + list(APPEND WASM_COMMAND -isystem ${folder}) + endforeach() + + foreach(folder ${ARG_SYSTEM_INCLUDE_FOLDERS}) + list(APPEND WASM_COMMAND -isystem ${folder}) + endforeach() + add_custom_command(OUTPUT ${outfile}.bc DEPENDS ${infile} COMMAND ${WASM_COMMAND} @@ -128,9 +147,9 @@ macro(compile_wast) endmacro(compile_wast) macro(add_wast_library) - cmake_parse_arguments(ARG "" "TARGET;DESTINATION_FOLDER" "SOURCE_FILES;INCLUDE_FOLDERS" ${ARGN}) + cmake_parse_arguments(ARG "NOWARNINGS" "TARGET;DESTINATION_FOLDER" "SOURCE_FILES;INCLUDE_FOLDERS;SYSTEM_INCLUDE_FOLDERS" ${ARGN}) set(target ${ARG_TARGET}) - compile_wast(TARGET ${ARG_TARGET} SOURCE_FILES ${ARG_SOURCE_FILES} INCLUDE_FOLDERS ${ARG_INCLUDE_FOLDERS}) + compile_wast(${ARGV}) get_filename_component("${ARG_TARGET}_BC_FILENAME" "${ARG_DESTINATION_FOLDER}/${ARG_TARGET}.bc" ABSOLUTE CACHE) add_custom_target(${target} ALL DEPENDS ${${ARG_TARGET}_BC_FILENAME}) @@ -146,11 +165,11 @@ macro(add_wast_library) endmacro(add_wast_library) macro(add_wast_executable) - cmake_parse_arguments(ARG "" "TARGET;DESTINATION_FOLDER" "SOURCE_FILES;INCLUDE_FOLDERS;LIBRARIES" ${ARGN}) + cmake_parse_arguments(ARG "NOWARNINGS" "TARGET;DESTINATION_FOLDER" "SOURCE_FILES;INCLUDE_FOLDERS;SYSTEM_INCLUDE_FOLDERS;LIBRARIES" ${ARGN}) set(target ${ARG_TARGET}) set(DESTINATION_FOLDER ${ARG_DESTINATION_FOLDER}) - compile_wast(TARGET ${ARG_TARGET} SOURCE_FILES ${ARG_SOURCE_FILES} INCLUDE_FOLDERS ${ARG_INCLUDE_FOLDERS}) + compile_wast(${ARGV}) foreach(lib ${ARG_LIBRARIES}) list(APPEND LIBRARIES ${${lib}_BC_FILENAME}) diff --git a/contracts/CMakeLists.txt b/contracts/CMakeLists.txt index 469ae00cc..e3c3c63d4 100644 --- a/contracts/CMakeLists.txt +++ b/contracts/CMakeLists.txt @@ -1,4 +1,8 @@ -set(STANDARD_INCLUDE_FOLDERS ${CMAKE_SOURCE_DIR}/contracts ${CMAKE_SOURCE_DIR}/contracts/libc++/upstream/include ${CMAKE_SOURCE_DIR}/contracts/musl/upstream/include ${Boost_INCLUDE_DIR}) +# will be implictly used for any compilation unit if not overrided by SYSTEM_INCLUDE_FOLDERS parameter +# these directories go as -isystem to avoid warnings from code of third-party libraries +set(DEFAULT_SYSTEM_INCLUDE_FOLDERS ${CMAKE_SOURCE_DIR}/contracts/libc++/upstream/include ${CMAKE_SOURCE_DIR}/contracts/musl/upstream/include ${Boost_INCLUDE_DIR}) + +set(STANDARD_INCLUDE_FOLDERS ${CMAKE_SOURCE_DIR}/contracts) add_subdirectory(eosiolib) add_subdirectory(musl) diff --git a/contracts/eosiolib/account.hpp b/contracts/eosiolib/account.hpp index 6b0871aa4..3520035ff 100644 --- a/contracts/eosiolib/account.hpp +++ b/contracts/eosiolib/account.hpp @@ -68,13 +68,13 @@ struct PACKED(account_balance) { /** * @brief Retrieve a populated balance structure * @details Retrieve a populated balance structure - * @param account_balance stream to write - * @ret true if account's balance is found + * @param acnt - account + * @return true if account's balance is found */ -bool get(account_balance& b) +bool get(account_balance& acnt) { - return account_balance_get(&b, sizeof(account_balance)); + return account_balance_get(&acnt, sizeof(account_balance)); } /// @} eosio diff --git a/contracts/eosiolib/action.h b/contracts/eosiolib/action.h index 7003e80e7..39558fcf0 100644 --- a/contracts/eosiolib/action.h +++ b/contracts/eosiolib/action.h @@ -112,8 +112,8 @@ extern "C" { /** * Send an inline action in the context of this action's parent transaction - * @param serialized_action - * @param size + * @param serialized_action - serialized action + * @param size - size of serialized action in bytes */ void send_inline(char *serialized_action, size_t size); diff --git a/contracts/eosiolib/datastream.hpp b/contracts/eosiolib/datastream.hpp index 9186d0a40..284c3f8d6 100644 --- a/contracts/eosiolib/datastream.hpp +++ b/contracts/eosiolib/datastream.hpp @@ -18,7 +18,7 @@ template class datastream { public: datastream( T start, size_t s ) - :_start(start),_pos(start),_end(start+s){}; + :_start(start),_pos(start),_end(start+s){} /** * Skips a specified number of bytes from this stream @@ -119,7 +119,7 @@ class datastream { template<> class datastream { public: - datastream( size_t init_size = 0):_size(init_size){}; + datastream( size_t init_size = 0):_size(init_size){} inline bool skip( size_t s ) { _size += s; return true; } inline bool write( const char* ,size_t s ) { _size += s; return true; } inline bool put(char ) { ++_size; return true; } diff --git a/contracts/eosiolib/eosiolib.cpp b/contracts/eosiolib/eosiolib.cpp index 9dfda4d04..cb4805ac3 100644 --- a/contracts/eosiolib/eosiolib.cpp +++ b/contracts/eosiolib/eosiolib.cpp @@ -75,7 +75,6 @@ namespace eosio { adjust_to_mem_block(size); // first pass of loop never has to initialize the slot in _available_heap - uint32_t needs_init = 0; char* buffer = nullptr; memory* current = nullptr; // need to make sure @@ -129,7 +128,6 @@ namespace eosio { return nullptr; } - const uint32_t REMOVE = size; adjust_to_mem_block(size); char* realloc_ptr = nullptr; diff --git a/contracts/eosiolib/math.h b/contracts/eosiolib/math.h index e6c7652ba..9aa41bea9 100644 --- a/contracts/eosiolib/math.h +++ b/contracts/eosiolib/math.h @@ -157,7 +157,7 @@ extern "C" { * Convert double (interpreted as 64 bit unsigned integer) to 64 bit unsigned integer. * This function will first reinterpret_cast the input to double (50 decimal digit precision) then convert it to double, then reinterpret_cast it to 64 bit unsigned integer. * @brief Convert double to 64 bit unsigned integer - * @param self Value in double interpreted as 64 bit unsigned integer + * @param a - value in double interpreted as 64 bit unsigned integer * @return Result of conversion in 64 bit unsigned integer * * Example: @@ -173,7 +173,7 @@ extern "C" { * Convert 64 bit unsigned integer to double (interpreted as 64 bit unsigned integer). * This function will convert the input to double (50 decimal digit precision) then reinterpret_cast it to 64 bit unsigned integer. * @brief Convert 64 bit unsigned integer to double (interpreted as 64 bit unsigned integer) - * @param self Value to be converted + * @param a - value to be converted * @return Result of conversion in double (interpreted as 64 bit unsigned integer) * * Example: diff --git a/contracts/eosiolib/multi_index.hpp b/contracts/eosiolib/multi_index.hpp index 63f3ad81d..15f6e6fca 100644 --- a/contracts/eosiolib/multi_index.hpp +++ b/contracts/eosiolib/multi_index.hpp @@ -266,7 +266,7 @@ class multi_index const T* operator->()const { return *static_cast(_item); } private: - friend class index; + friend struct index; const_iterator( const index& idx, const typename MultiIndexType::item* i = nullptr ) :_idx(idx), _item(i){} diff --git a/contracts/eosiolib/print.h b/contracts/eosiolib/print.h index 1f2606e25..109365ddb 100644 --- a/contracts/eosiolib/print.h +++ b/contracts/eosiolib/print.h @@ -51,7 +51,7 @@ extern "C" { /** * Prints value as a 64 bit unsigned integer * @brief Prints value as a 64 bit unsigned integer - * @param Value of 64 bit unsigned integer to be printed + * @param value of 64 bit unsigned integer to be printed * * Example: * @code @@ -76,7 +76,7 @@ extern "C" { /** * Prints value as double * @brief Prints value as double - * @param Value of double (interpreted as 64 bit unsigned integer) to be printed + * @param value of double (interpreted as 64 bit unsigned integer) to be printed * * Example: * @code @@ -89,7 +89,7 @@ extern "C" { /** * Prints a 64 bit names as base32 encoded string * @brief Prints a 64 bit names as base32 encoded string - * @param Value of 64 bit names to be printed + * @param name - 64 bit name to be printed * * Example: * @code diff --git a/contracts/eosiolib/print.hpp b/contracts/eosiolib/print.hpp index 0c994a9e4..236a05f8b 100644 --- a/contracts/eosiolib/print.hpp +++ b/contracts/eosiolib/print.hpp @@ -14,7 +14,7 @@ namespace eosio { /** * Prints string * @brief Prints string - * @param cstr - a null terminated string + * @param ptr - a null terminated string */ inline void print( const char* ptr ) { prints(ptr); @@ -23,7 +23,7 @@ namespace eosio { /** * Prints 64 bit unsigned integer as a 64 bit unsigned integer * @brief Prints integer 64 bit unsigned integer - * @param Value to be printed + * @param num to be printed */ inline void print( uint64_t num ) { printi(num); @@ -32,7 +32,7 @@ namespace eosio { /** * Prints 32 bit unsigned integer as a 64 bit unsigned integer * @brief Prints integer 32 bit unsigned integer - * @param Value to be printed + * @param num to be printed */ inline void print( uint32_t num ) { printi(num); @@ -41,7 +41,7 @@ namespace eosio { /** * Prints integer as a 64 bit unsigned integer * @brief Prints integer - * @param Value to be printed + * @param num to be printed */ inline void print( int num ) { printi(num); @@ -50,7 +50,7 @@ namespace eosio { /** * Prints unsigned integer as a 64 bit unsigned integer * @brief Prints unsigned integer - * @param Value to be printed + * @param num to be printed */ inline void print( unsigned int num ) { printi(num); @@ -59,7 +59,7 @@ namespace eosio { /** * Prints uint128 struct as 128 bit unsigned integer * @brief Prints uint128 struct - * @param Value to be printed + * @param num to be printed */ inline void print( uint128 num ) { printi128((uint128_t*)&num); @@ -68,7 +68,7 @@ namespace eosio { /** * Prints 128 bit unsigned integer * @brief Prints 128 bit unsigned integer - * @param Value to be printed + * @param num to be printed */ inline void print( uint128_t num ) { printi128((uint128_t*)&num); @@ -77,7 +77,7 @@ namespace eosio { /** * Prints a 64 bit names as base32 encoded string * @brief Prints a 64 bit names as base32 encoded string - * @param Value of 64 bit names to be printed + * @param name 64 bit name to be printed */ inline void print( name name ) { printn(name.value); diff --git a/contracts/eosiolib/real.hpp b/contracts/eosiolib/real.hpp index ddf18ca2c..6a6a394d9 100644 --- a/contracts/eosiolib/real.hpp +++ b/contracts/eosiolib/real.hpp @@ -92,8 +92,6 @@ namespace eosio { * @brief Compares two double variables c1 and c2 * * @details Compares two double variables c1 and c2 - * @param c1 - * @param c2 * @return if c1 == c2, return true, otherwise false */ bool operator==(const real &c1, const real &c2) { @@ -105,8 +103,6 @@ namespace eosio { * @brief Compares two double variables c1 and c2 * * @details Compares two double variables c1 and c2 - * @param c1 - * @param c2 * @return if c1 > c2, return true, otherwise false */ bool operator>(const real &c1, const real &c2) { @@ -118,8 +114,6 @@ namespace eosio { * @brief Compares two double variables c1 and c2 * * @details Compares two double variables c1 and c2 - * @param c1 - * @param c2 * @return if c1 < c2, return true, otherwise false */ bool operator<(const real &c1, const real &c2) { diff --git a/contracts/eosiolib/token.hpp b/contracts/eosiolib/token.hpp index aa9aa9cf6..6ecedc0f4 100644 --- a/contracts/eosiolib/token.hpp +++ b/contracts/eosiolib/token.hpp @@ -49,7 +49,7 @@ namespace eosio { * @brief Constructor for token given quantity of tokens available * @param v - quantity of tokens available */ - explicit token( NumberType v ):quantity(v){}; + explicit token( NumberType v ):quantity(v){} /** * Quantity of tokens available diff --git a/contracts/eosiolib/transaction.h b/contracts/eosiolib/transaction.h index 749706b46..257224d3f 100644 --- a/contracts/eosiolib/transaction.h +++ b/contracts/eosiolib/transaction.h @@ -72,26 +72,22 @@ extern "C" { /** * get the size of the currently executing transaction - * @return */ size_t transaction_size(); /** * get the block number used for TAPOS on the currently executing transaction * - * @return */ int tapos_block_num(); /** * get the block prefix used for TAPOS on the currently executing transaction - * @return */ int tapos_block_prefix(); /** * get the expiration of the currently executing transaction - * @return */ time expiration(); diff --git a/contracts/eosiolib/transaction.hpp b/contracts/eosiolib/transaction.hpp index 5dc0e2cf1..2890edb64 100644 --- a/contracts/eosiolib/transaction.hpp +++ b/contracts/eosiolib/transaction.hpp @@ -24,8 +24,8 @@ namespace eosio { class transaction { public: - transaction(time expiration = now() + 60, region_id region = 0) - :expiration(expiration),region(region) + transaction(time exp = now() + 60, region_id r = 0) + :expiration(exp),region(r) {} void send(uint32_t sender_id, time delay_until = 0) const { @@ -43,7 +43,7 @@ namespace eosio { vector context_free_actions; vector actions; - EOSLIB_SERIALIZE( transaction, (expiration)(region)(ref_block_num)(ref_block_prefix)(packed_bandwidth_words)(context_free_cpu_bandwidth)(context_free_actions)(actions) ); + EOSLIB_SERIALIZE( transaction, (expiration)(region)(ref_block_num)(ref_block_prefix)(packed_bandwidth_words)(context_free_cpu_bandwidth)(context_free_actions)(actions) ) }; class deferred_transaction : public transaction { diff --git a/contracts/eosiolib/types.hpp b/contracts/eosiolib/types.hpp index df08e24b9..e4ab9f1f2 100644 --- a/contracts/eosiolib/types.hpp +++ b/contracts/eosiolib/types.hpp @@ -13,7 +13,7 @@ namespace eosio { * @details Converts a base32 symbol into its binary representation, used by string_to_name() * @ingroup types */ - static constexpr char char_to_symbol( char c ) { + static constexpr char char_to_symbol( char c ) { if( c >= 'a' && c <= 'z' ) return (c - 'a') + 6; if( c >= '1' && c <= '5' ) diff --git a/contracts/eosiolib/varint.hpp b/contracts/eosiolib/varint.hpp index c931e4dea..3fd084b5a 100644 --- a/contracts/eosiolib/varint.hpp +++ b/contracts/eosiolib/varint.hpp @@ -23,7 +23,7 @@ struct unsigned_int { template operator T()const { return static_cast(value); } - unsigned_int& operator=( int32_t v ) { value = v; return *this; } + unsigned_int& operator=( uint32_t v ) { value = v; return *this; } uint32_t value; diff --git a/contracts/libc++/CMakeLists.txt b/contracts/libc++/CMakeLists.txt index 72fd6a785..d59707a64 100644 --- a/contracts/libc++/CMakeLists.txt +++ b/contracts/libc++/CMakeLists.txt @@ -9,6 +9,7 @@ FOREACH(FN ${SRC_FILENAMES}) ENDFOREACH(FN) add_wast_library(TARGET libc++ + NOWARNINGS SOURCE_FILES "${SRC_FILES}" INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}" DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR} diff --git a/contracts/multi_index_test/CMakeLists.txt b/contracts/multi_index_test/CMakeLists.txt index c1f0faf35..50606049b 100644 --- a/contracts/multi_index_test/CMakeLists.txt +++ b/contracts/multi_index_test/CMakeLists.txt @@ -2,7 +2,7 @@ file(GLOB ABI_FILES "*.abi") set(ABI_FILES "multi_index_test.abi") add_wast_executable(TARGET multi_index_test - INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}" /usr/local/include + INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}" LIBRARIES libc++ libc eosiolib DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/contracts/musl/CMakeLists.txt b/contracts/musl/CMakeLists.txt index c4df0b239..30912e0b5 100644 --- a/contracts/musl/CMakeLists.txt +++ b/contracts/musl/CMakeLists.txt @@ -16,6 +16,7 @@ file(GLOB THREAD_SOURCES "upstream/src/thread/*.c") #only for __lock __unlock set(INTERNAL_SOURCES upstream/src/internal/intscan.c upstream/src/internal/shgetc.c upstream/src/internal/libc.c) add_wast_library(TARGET libc + NOWARNINGS SOURCE_FILES ${CRYPT_SOURCES} ${CTYPE_SOURCES} ${ENV_SOURCES} ${ERRNO_SOURCES} ${EXIT_SOURCES} ${INTERNAL_SOURCES} ${LOCALE_SOURCES} ${MBYTE_SOURCES} ${MISC_SOURCES} ${SEARCH_SOURCES} ${STDIO_SOURCES} ${STDLIB_SOURCES} ${STRING_SOURCES} ${TIME_SOURCES} ${THREAD_SOURCES} INCLUDE_FOLDERS ${CMAKE_SOURCE_DIR}/contracts/musl/upstream/include diff --git a/contracts/stltest/stltest.cpp b/contracts/stltest/stltest.cpp index d2b37110f..1cd4fe317 100644 --- a/contracts/stltest/stltest.cpp +++ b/contracts/stltest/stltest.cpp @@ -2,8 +2,6 @@ * @file * @copyright defined in eos/LICENSE.txt */ -#include /// defines transfer struct (abi) - // include entire libc #include #include diff --git a/contracts/stltest/stltest.hpp b/contracts/stltest/stltest.hpp deleted file mode 100644 index 7b9637ef9..000000000 --- a/contracts/stltest/stltest.hpp +++ /dev/null @@ -1 +0,0 @@ -#pragma once \ No newline at end of file -- GitLab