Commit 6aa9cb02 authored by Kenton Varda's avatar Kenton Varda

Twiddle the set of warnings that we test against in super-test.sh.

I've added -Wextra as well as removed some of the -Wno-* flags and fixed issues in the code.

Also fixed the cmake build to put user-defined flags after default flags so that they can be overridden.
parent ebf43a8c
...@@ -7,7 +7,7 @@ include(CheckIncludeFileCXX) ...@@ -7,7 +7,7 @@ include(CheckIncludeFileCXX)
if(MSVC) if(MSVC)
check_include_file_cxx(initializer_list HAS_CXX11) check_include_file_cxx(initializer_list HAS_CXX11)
else() else()
check_include_file_cxx(initializer_list HAS_CXX11 "-std=c++11") check_include_file_cxx(initializer_list HAS_CXX11 "-std=gnu++0x")
endif() endif()
if(NOT HAS_CXX11) if(NOT HAS_CXX11)
message(SEND_ERROR "Requires a C++11 compiler and standard library.") message(SEND_ERROR "Requires a C++11 compiler and standard library.")
...@@ -61,9 +61,24 @@ else() ...@@ -61,9 +61,24 @@ else()
endif() endif()
if(MSVC) if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 ${CAPNP_LITE_FLAG}") # TODO(cleanup): Enable higher warning level in MSVC, but make sure to test
# build with that warning level and clean out false positives.
set(CMAKE_CXX_FLAGS "${CAPNP_LITE_FLAG} ${CMAKE_CXX_FLAGS}")
else() else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -std=c++11 -pthread ${CAPNP_LITE_FLAG}") # Note that it's important to add new CXXFLAGS before ones specified by the
# user, so that the user's flags override them. This is particularly
# important if -Werror was enabled and then certain warnings need to be
# disabled, as is done in super-test.sh.
#
# We enable a lot of warnings, but then disable some:
# * strict-aliasing: We use type-punning in known-safe ways that GCC doesn't
# recognize as safe.
# * sign-compare: Low S/N ratio.
# * unused-parameter: Low S/N ratio.
#
# We have to use -std=gnu++0x isntead of -std=c++11 because otherwise we lose
# GNU extensions that we need.
set(CMAKE_CXX_FLAGS "-std=gnu++0x -Wall -Wextra -Wno-strict-aliasing -Wno-sign-compare -Wno-unused-parameter -pthread ${CAPNP_LITE_FLAG} ${CMAKE_CXX_FLAGS}")
endif() endif()
# Source ======================================================================= # Source =======================================================================
......
...@@ -37,7 +37,7 @@ clean-local: ...@@ -37,7 +37,7 @@ clean-local:
# the cmake build. # the cmake build.
distcheck-hook: distcheck-hook:
rm -rf distcheck-cmake rm -rf distcheck-cmake
(which cmake && mkdir distcheck-cmake && cd distcheck-cmake && cmake ../$(distdir) && make -j6 check) (mkdir distcheck-cmake && cd distcheck-cmake && cmake ../$(distdir) && make -j6 check)
rm -rf distcheck-cmake rm -rf distcheck-cmake
AM_CXXFLAGS = -I$(srcdir)/src -I$(builddir)/src -DKJ_HEADER_WARNINGS -DCAPNP_HEADER_WARNINGS -DCAPNP_INCLUDE_DIR='"$(includedir)"' $(PTHREAD_CFLAGS) AM_CXXFLAGS = -I$(srcdir)/src -I$(builddir)/src -DKJ_HEADER_WARNINGS -DCAPNP_HEADER_WARNINGS -DCAPNP_INCLUDE_DIR='"$(includedir)"' $(PTHREAD_CFLAGS)
......
...@@ -333,7 +333,10 @@ kj::Promise<kj::Own<_::VatNetworkBase::Connection>> ...@@ -333,7 +333,10 @@ kj::Promise<kj::Own<_::VatNetworkBase::Connection>>
template <typename SturdyRef> template <typename SturdyRef>
Capability::Client SturdyRefRestorer<SturdyRef>::baseRestore(AnyPointer::Reader ref) { Capability::Client SturdyRefRestorer<SturdyRef>::baseRestore(AnyPointer::Reader ref) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
return restore(ref.getAs<SturdyRef>()); return restore(ref.getAs<SturdyRef>());
#pragma GCC diagnostic pop
} }
template <typename VatId> template <typename VatId>
......
...@@ -274,7 +274,7 @@ public: ...@@ -274,7 +274,7 @@ public:
data.append(reinterpret_cast<const char*>(buffer), size); data.append(reinterpret_cast<const char*>(buffer), size);
} }
const bool dataEquals(kj::ArrayPtr<const word> other) { bool dataEquals(kj::ArrayPtr<const word> other) {
return data == return data ==
std::string(other.asChars().begin(), other.asChars().size()); std::string(other.asChars().begin(), other.asChars().size());
} }
......
...@@ -149,7 +149,12 @@ void registerReservedSignal() { ...@@ -149,7 +149,12 @@ void registerReservedSignal() {
registerSignalHandler(reservedSignal); registerSignalHandler(reservedSignal);
// We also disable SIGPIPE because users of UnixEventLoop almost certainly don't want it. // We also disable SIGPIPE because users of UnixEventLoop almost certainly don't want it.
KJ_SYSCALL(signal(SIGPIPE, SIG_IGN)); while (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
int error = errno;
if (error != EINTR) {
KJ_FAIL_SYSCALL("signal(SIGPIPE, SIG_IGN)", error);
}
}
} }
pthread_once_t registerReservedSignalOnce = PTHREAD_ONCE_INIT; pthread_once_t registerReservedSignalOnce = PTHREAD_ONCE_INIT;
...@@ -746,7 +751,8 @@ bool UnixEventPort::wait() { ...@@ -746,7 +751,8 @@ bool UnixEventPort::wait() {
} }
bool UnixEventPort::poll() { bool UnixEventPort::poll() {
bool woken = false; // volatile so that longjmp() doesn't clobber it.
volatile bool woken = false;
sigset_t pending; sigset_t pending;
sigset_t waitMask; sigset_t waitMask;
......
linux-gcc-4.9 9081 ./super-test.sh tmpdir capnp-gcc-4.9 gcc-4.9 linux-gcc-4.9 10520 ./super-test.sh tmpdir capnp-gcc-4.9 gcc-4.9
linux-gcc-4.8 8358 ./super-test.sh tmpdir capnp-gcc-4.8 gcc-4.8 linux-gcc-4.8 9800 ./super-test.sh tmpdir capnp-gcc-4.8 gcc-4.8
linux-clang 9165 ./super-test.sh tmpdir capnp-clang clang linux-clang 10616 ./super-test.sh tmpdir capnp-clang clang
mac 6421 ./super-test.sh remote beat caffeinate mac 7942 ./super-test.sh remote beat caffeinate
cygwin 9770 ./super-test.sh remote Kenton@flashman cygwin 9044 ./super-test.sh remote Kenton@flashman
exotic 4216 ./super-test.sh tmpdir exotic exotic exotic 5581 ./super-test.sh tmpdir exotic exotic
...@@ -60,7 +60,7 @@ while [ $# -gt 0 ]; do ...@@ -60,7 +60,7 @@ while [ $# -gt 0 ]; do
echo "Pushing code to $HOST..." echo "Pushing code to $HOST..."
echo "=========================================================================" echo "========================================================================="
BRANCH=$(git rev-parse --abbrev-ref HEAD) BRANCH=$(git rev-parse --abbrev-ref HEAD)
ssh $HOST 'rm -rf tmp-test-capnp && mkdir tmp-test-capnp && git init tmp-test-capnp' ssh $HOST 'chmod -R +w tmp-test-capnp && rm -rf tmp-test-capnp && mkdir tmp-test-capnp && git init tmp-test-capnp'
git push ssh://$HOST/~/tmp-test-capnp "$BRANCH:test" git push ssh://$HOST/~/tmp-test-capnp "$BRANCH:test"
ssh $HOST "cd tmp-test-capnp && git checkout test" ssh $HOST "cd tmp-test-capnp && git checkout test"
scp -qr c++/gtest $HOST:~/tmp-test-capnp/c++/gtest scp -qr c++/gtest $HOST:~/tmp-test-capnp/c++/gtest
...@@ -209,8 +209,9 @@ done ...@@ -209,8 +209,9 @@ done
# Enable lots of warnings and make sure the build breaks if they fire. Disable strict-aliasing # Enable lots of warnings and make sure the build breaks if they fire. Disable strict-aliasing
# because GCC warns about code that I know is OK. Disable sign-compare because I've fixed more # because GCC warns about code that I know is OK. Disable sign-compare because I've fixed more
# sign-compare warnings than probably all other warnings combined and I've never seen it flag a # sign-compare warnings than probably all other warnings combined and I've never seen it flag a
# real problem. # real problem. Disable unused parameters because it's stupidly noisy and never a real problem.
export CXXFLAGS="-O2 -DDEBUG -Wall -Werror -Wno-strict-aliasing -Wno-sign-compare -Wno-deprecated-declarations" # Disable missing-field-initializers because unfortuntaley gtest contains a warning of this class.
export CXXFLAGS="-O2 -DDEBUG -Wall -Wextra -Werror -Wno-strict-aliasing -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers"
STAGING=$PWD/tmp-staging STAGING=$PWD/tmp-staging
...@@ -238,14 +239,13 @@ else ...@@ -238,14 +239,13 @@ else
fi fi
if [ $IS_CLANG = yes ]; then if [ $IS_CLANG = yes ]; then
# There's an unused private field in gtest. # There's an unused private field in gtest, which Clang dislikes.
export CXXFLAGS="$CXXFLAGS -Wno-unused-private-field" #
# Also, don't fail out on this ridiculous "argument unused during compilation" warning.
export CXXFLAGS="$CXXFLAGS -Wno-unused-private-field -Wno-error=unused-command-line-argument"
else else
# GCC 4.8 emits a weird uninitialized warning in kj/parse/char-test, deep in one of the parser # GCC emits uninitialized warnings all over and they seem bogus. We use valgrind to test for
# combinators. It could be a real bug but there is just not enough information to figure out # uninitialized memory usage later on.
# where the problem is coming from, because GCC does not provide any description of the inlining
# that has occurred. Since I have not observed any actual problem (tests pass, etc.), I'm
# muting it for now.
CXXFLAGS="$CXXFLAGS -Wno-maybe-uninitialized" CXXFLAGS="$CXXFLAGS -Wno-maybe-uninitialized"
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment