Enable "-Wextra" compiler option and fix code to remove warnings

"-Wextra" option turns on the following warnings:
 -Wclobbered
 -Wempty-body
 -Wignored-qualifiers
 -Wmissing-field-initializers
 -Wmissing-parameter-type (C only)
 -Wold-style-declaration (C only)
 -Woverride-init
 -Wsign-compare
 -Wtype-limits
 -Wuninitialized
 -Wunused-parameter (only with -Wunused or -Wall)
 -Wunused-but-set-parameter (only with -Wunused or -Wall)
This commit is contained in:
Soonho Kong 2013-09-19 22:52:52 -07:00
parent 651c5d6751
commit 49e87ccbb1
3 changed files with 9 additions and 3 deletions

View file

@ -25,7 +25,7 @@ endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# Initialize CXXFLAGS.
set(CMAKE_CXX_FLAGS "-Wall -Wunused-parameter -std=c++11 ${LEAN_EXTRA_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++11 ${LEAN_EXTRA_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DLEAN_DEBUG -DLEAN_TRACE")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")

View file

@ -33,7 +33,10 @@ unsigned hash_str(unsigned length, char const * str, unsigned init_value) {
a += reinterpret_cast<unsigned const *>(str)[0];
b += reinterpret_cast<unsigned const *>(str)[1];
c += reinterpret_cast<unsigned const *>(str)[2];
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wextra"
mix(a, b, c);
#pragma GCC diagnostic pop
str += 12; len -= 12;
}
@ -55,7 +58,10 @@ unsigned hash_str(unsigned length, char const * str, unsigned init_value) {
case 1 : a+=str[0];
/* case 0: nothing left to add */
}
mix(a, b, c);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wextra"
mix(a, b, c);
#pragma GCC diagnostic pop
/*-------------------------------------------- report the result */
return c;
}

View file

@ -88,7 +88,7 @@ private:
lean_assert(sexpr_kind(s) == format_kind::TEXT);
return cdr(s);
}
static inline size_t const sexpr_text_length(sexpr const & s) {
static inline size_t sexpr_text_length(sexpr const & s) {
lean_assert(sexpr_kind(s) == format_kind::TEXT);
std::stringstream ss;
sexpr const & content = cdr(s);