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)
if(MSVC)
check_include_file_cxx(initializer_list HAS_CXX11)
else()
check_include_file_cxx(initializer_list HAS_CXX11 "-std=c++11")
check_include_file_cxx(initializer_list HAS_CXX11 "-std=gnu++0x")
endif()
if(NOT HAS_CXX11)
message(SEND_ERROR "Requires a C++11 compiler and standard library.")
......@@ -61,9 +61,24 @@ else()
endif()
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()
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()
# Source =======================================================================
......
......@@ -37,7 +37,7 @@ clean-local:
# the cmake build.
distcheck-hook:
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
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>>
template <typename SturdyRef>
Capability::Client SturdyRefRestorer<SturdyRef>::baseRestore(AnyPointer::Reader ref) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
return restore(ref.getAs<SturdyRef>());
#pragma GCC diagnostic pop
}
template <typename VatId>
......
......@@ -274,7 +274,7 @@ public:
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 ==
std::string(other.asChars().begin(), other.asChars().size());
}
......
......@@ -149,7 +149,12 @@ void registerReservedSignal() {
registerSignalHandler(reservedSignal);
// 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;
......@@ -746,7 +751,8 @@ bool UnixEventPort::wait() {
}
bool UnixEventPort::poll() {
bool woken = false;
// volatile so that longjmp() doesn't clobber it.
volatile bool woken = false;
sigset_t pending;
sigset_t waitMask;
......
linux-gcc-4.9 9081 ./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-clang 9165 ./super-test.sh tmpdir capnp-clang clang
mac 6421 ./super-test.sh remote beat caffeinate
cygwin 9770 ./super-test.sh remote Kenton@flashman
exotic 4216 ./super-test.sh tmpdir exotic exotic
linux-gcc-4.9 10520 ./super-test.sh tmpdir capnp-gcc-4.9 gcc-4.9
linux-gcc-4.8 9800 ./super-test.sh tmpdir capnp-gcc-4.8 gcc-4.8
linux-clang 10616 ./super-test.sh tmpdir capnp-clang clang
mac 7942 ./super-test.sh remote beat caffeinate
cygwin 9044 ./super-test.sh remote Kenton@flashman
exotic 5581 ./super-test.sh tmpdir exotic exotic
......@@ -60,7 +60,7 @@ while [ $# -gt 0 ]; do
echo "Pushing code to $HOST..."
echo "========================================================================="
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"
ssh $HOST "cd tmp-test-capnp && git checkout test"
scp -qr c++/gtest $HOST:~/tmp-test-capnp/c++/gtest
......@@ -209,8 +209,9 @@ done
# 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
# sign-compare warnings than probably all other warnings combined and I've never seen it flag a
# real problem.
export CXXFLAGS="-O2 -DDEBUG -Wall -Werror -Wno-strict-aliasing -Wno-sign-compare -Wno-deprecated-declarations"
# real problem. Disable unused parameters because it's stupidly noisy and never a real problem.
# 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
......@@ -238,14 +239,13 @@ else
fi
if [ $IS_CLANG = yes ]; then
# There's an unused private field in gtest.
export CXXFLAGS="$CXXFLAGS -Wno-unused-private-field"
# There's an unused private field in gtest, which Clang dislikes.
#
# 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
# GCC 4.8 emits a weird uninitialized warning in kj/parse/char-test, deep in one of the parser
# combinators. It could be a real bug but there is just not enough information to figure out
# 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.
# GCC emits uninitialized warnings all over and they seem bogus. We use valgrind to test for
# uninitialized memory usage later on.
CXXFLAGS="$CXXFLAGS -Wno-maybe-uninitialized"
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