Enable more warnings and -Werror in test script, fix problems.
diff --git a/c++/src/capnp/common.h b/c++/src/capnp/common.h
index 754b2ab..1660f7a 100644
--- a/c++/src/capnp/common.h
+++ b/c++/src/capnp/common.h
@@ -269,13 +269,14 @@
constexpr ElementCount ELEMENTS = kj::unit<ElementCount>();
constexpr WirePointerCount POINTERS = kj::unit<WirePointerCount>();
-constexpr auto BITS_PER_BYTE = 8 * BITS / BYTES;
-constexpr auto BITS_PER_WORD = 64 * BITS / WORDS;
-constexpr auto BYTES_PER_WORD = 8 * BYTES / WORDS;
+// GCC 4.7 actually gives unused warnings on these constants in opt mode...
+constexpr auto BITS_PER_BYTE KJ_UNUSED = 8 * BITS / BYTES;
+constexpr auto BITS_PER_WORD KJ_UNUSED = 64 * BITS / WORDS;
+constexpr auto BYTES_PER_WORD KJ_UNUSED = 8 * BYTES / WORDS;
-constexpr auto BITS_PER_POINTER = 64 * BITS / POINTERS;
-constexpr auto BYTES_PER_POINTER = 8 * BYTES / POINTERS;
-constexpr auto WORDS_PER_POINTER = 1 * WORDS / POINTERS;
+constexpr auto BITS_PER_POINTER KJ_UNUSED = 64 * BITS / POINTERS;
+constexpr auto BYTES_PER_POINTER KJ_UNUSED = 8 * BYTES / POINTERS;
+constexpr auto WORDS_PER_POINTER KJ_UNUSED = 1 * WORDS / POINTERS;
constexpr WordCount POINTER_SIZE_IN_WORDS = 1 * POINTERS * WORDS_PER_POINTER;
diff --git a/c++/src/capnp/compiler/capnpc-c++.c++ b/c++/src/capnp/compiler/capnpc-c++.c++
index 6692893..e8360af 100644
--- a/c++/src/capnp/compiler/capnpc-c++.c++
+++ b/c++/src/capnp/compiler/capnpc-c++.c++
@@ -599,7 +599,7 @@
auto nonGroup = proto.getNonGroup();
- FieldKind kind;
+ FieldKind kind = FieldKind::PRIMITIVE;
kj::String ownedType;
kj::String type = typeName(nonGroup.getType()).flatten();
kj::StringPtr setterDefault; // only for void
diff --git a/c++/src/capnp/schema-loader.c++ b/c++/src/capnp/schema-loader.c++
index 9261f4f..00d6321 100644
--- a/c++/src/capnp/schema-loader.c++
+++ b/c++/src/capnp/schema-loader.c++
@@ -312,8 +312,8 @@
case schema::Field::NON_GROUP: {
auto nonGroup = field.getNonGroup();
- uint fieldBits;
- bool fieldIsPointer;
+ uint fieldBits = 0;
+ bool fieldIsPointer = false;
validate(nonGroup.getType(), nonGroup.getDefaultValue(),
&fieldBits, &fieldIsPointer);
VALIDATE_SCHEMA(fieldBits * (nonGroup.getOffset() + 1) <= dataSizeInBits &&
diff --git a/c++/src/kj/string-tree-test.c++ b/c++/src/kj/string-tree-test.c++
index b6f691f..f7a21b2 100644
--- a/c++/src/kj/string-tree-test.c++
+++ b/c++/src/kj/string-tree-test.c++
@@ -39,8 +39,8 @@
EXPECT_EQ("foobarbaz", tree.flatten());
uint pieceCount = 0;
- tree.visit([&](ArrayPtr<const char> part) { ++pieceCount; EXPECT_EQ(3, part.size()); });
- EXPECT_EQ(3, pieceCount);
+ tree.visit([&](ArrayPtr<const char> part) { ++pieceCount; EXPECT_EQ(3u, part.size()); });
+ EXPECT_EQ(3u, pieceCount);
}
EXPECT_EQ("<foobarbaz>", str('<', strTree(str("foo"), "bar", str("baz")), '>'));
diff --git a/super-test.sh b/super-test.sh
index 3476ab5..6b2ea85 100755
--- a/super-test.sh
+++ b/super-test.sh
@@ -152,8 +152,9 @@
done
# Build optimized builds because they catch more problems, but also enable debugging macros.
-# Enable lots of warnings and make sure the build breaks if they fire.
-export CXXFLAGS="-O2 -DDEBUG -Wall -Werror"
+# 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.
+export CXXFLAGS="-O2 -DDEBUG -Wall -Werror -Wno-strict-aliasing"
STAGING=$PWD/tmp-staging
@@ -185,6 +186,13 @@
SAMPLE_CXXFLAGS=
fi
+case ${CXX:-g++} in
+ *clang* )
+ # There's an unused private field in gtest.
+ export CXXFLAGS="$CXXFLAGS -Wno-unused-private-field"
+ ;;
+esac
+
cd c++
doit ./setup-autotools.sh | tr = -
doit autoreconf -i