Commit 5c5cd461 authored by Kenton Varda's avatar Kenton Varda

Fix GCC problems.

parent 0c93fd60
...@@ -233,6 +233,7 @@ public: ...@@ -233,6 +233,7 @@ public:
kj::MainBuilder::Validity generateId() { kj::MainBuilder::Validity generateId() {
context.exitInfo(kj::str("@0x", kj::hex(generateRandomId()))); context.exitInfo(kj::str("@0x", kj::hex(generateRandomId())));
KJ_CLANG_KNOWS_THIS_IS_UNREACHABLE_BUT_GCC_DOESNT;
} }
// ===================================================================================== // =====================================================================================
......
...@@ -546,6 +546,7 @@ private: ...@@ -546,6 +546,7 @@ private:
return kj::strTree( return kj::strTree(
"!_reader.isPointerFieldNull(", slot.offset, " * ::capnp::POINTERS)"); "!_reader.isPointerFieldNull(", slot.offset, " * ::capnp::POINTERS)");
} }
KJ_UNREACHABLE;
}, "\n || "), ";\n" }, "\n || "), ";\n"
"}\n" "}\n"
"inline bool ", scope, "Builder::has", titleCase, "() {\n", "inline bool ", scope, "Builder::has", titleCase, "() {\n",
...@@ -563,6 +564,7 @@ private: ...@@ -563,6 +564,7 @@ private:
return kj::strTree( return kj::strTree(
"!_builder.isPointerFieldNull(", slot.offset, " * ::capnp::POINTERS)"); "!_builder.isPointerFieldNull(", slot.offset, " * ::capnp::POINTERS)");
} }
KJ_UNREACHABLE;
}, "\n || "), ";\n" }, "\n || "), ";\n"
"}\n" "}\n"
"inline ", scope, titleCase, "::Reader ", scope, "Reader::get", titleCase, "() const {\n", "inline ", scope, titleCase, "::Reader ", scope, "Reader::get", titleCase, "() const {\n",
...@@ -587,6 +589,7 @@ private: ...@@ -587,6 +589,7 @@ private:
return kj::strTree( return kj::strTree(
" _builder.clearPointer(", slot.offset, " * ::capnp::POINTERS);\n"); " _builder.clearPointer(", slot.offset, " * ::capnp::POINTERS);\n");
} }
KJ_UNREACHABLE;
}, },
" return ", scope, titleCase, "::Builder(_builder);\n" " return ", scope, titleCase, "::Builder(_builder);\n"
"}\n") "}\n")
......
...@@ -345,9 +345,12 @@ private: ...@@ -345,9 +345,12 @@ private:
} else { } else {
seenUnion = true; seenUnion = true;
uint offset = schema.getProto().getStruct().getDiscriminantOffset(); uint offset = schema.getProto().getStruct().getDiscriminantOffset();
// GCC 4.7.3 crashes if you inline unionFields.
auto unionFields = sortByCodeOrder(schema.getUnionFields());
return kj::strTree( return kj::strTree(
indent, "union { # tag bits [", offset * 16, ", ", offset * 16 + 16, ")\n", indent, "union { # tag bits [", offset * 16, ", ", offset * 16 + 16, ")\n",
KJ_MAP(sortByCodeOrder(schema.getUnionFields()), uField) { KJ_MAP(unionFields, uField) {
return genStructField(uField.getProto(), schema, indent.next()); return genStructField(uField.getProto(), schema, indent.next());
}, },
indent, "}\n"); indent, "}\n");
......
...@@ -379,8 +379,8 @@ TEST(Encoding, UnnamedUnion) { ...@@ -379,8 +379,8 @@ TEST(Encoding, UnnamedUnion) {
EXPECT_TRUE(root.hasBar()); EXPECT_TRUE(root.hasBar());
EXPECT_FALSE(root.asReader().hasFoo()); EXPECT_FALSE(root.asReader().hasFoo());
EXPECT_TRUE(root.asReader().hasBar()); EXPECT_TRUE(root.asReader().hasBar());
EXPECT_EQ(321, root.getBar()); EXPECT_EQ(321u, root.getBar());
EXPECT_EQ(321, root.asReader().getBar()); EXPECT_EQ(321u, root.asReader().getBar());
EXPECT_DEBUG_ANY_THROW(root.getFoo()); EXPECT_DEBUG_ANY_THROW(root.getFoo());
EXPECT_DEBUG_ANY_THROW(root.asReader().getFoo()); EXPECT_DEBUG_ANY_THROW(root.asReader().getFoo());
...@@ -391,17 +391,17 @@ TEST(Encoding, UnnamedUnion) { ...@@ -391,17 +391,17 @@ TEST(Encoding, UnnamedUnion) {
EXPECT_FALSE(root.hasBar()); EXPECT_FALSE(root.hasBar());
EXPECT_TRUE(root.asReader().hasFoo()); EXPECT_TRUE(root.asReader().hasFoo());
EXPECT_FALSE(root.asReader().hasBar()); EXPECT_FALSE(root.asReader().hasBar());
EXPECT_EQ(123, root.getFoo()); EXPECT_EQ(123u, root.getFoo());
EXPECT_EQ(123, root.asReader().getFoo()); EXPECT_EQ(123u, root.asReader().getFoo());
EXPECT_DEBUG_ANY_THROW(root.getBar()); EXPECT_DEBUG_ANY_THROW(root.getBar());
EXPECT_DEBUG_ANY_THROW(root.asReader().getBar()); EXPECT_DEBUG_ANY_THROW(root.asReader().getBar());
StructSchema schema = Schema::from<test::TestUnnamedUnion>(); StructSchema schema = Schema::from<test::TestUnnamedUnion>();
// The discriminant is allocated just before allocating "bar". // The discriminant is allocated just before allocating "bar".
EXPECT_EQ(2, schema.getProto().getStruct().getDiscriminantOffset()); EXPECT_EQ(2u, schema.getProto().getStruct().getDiscriminantOffset());
EXPECT_EQ(0, schema.getFieldByName("foo").getProto().getNonGroup().getOffset()); EXPECT_EQ(0u, schema.getFieldByName("foo").getProto().getNonGroup().getOffset());
EXPECT_EQ(2, schema.getFieldByName("bar").getProto().getNonGroup().getOffset()); EXPECT_EQ(2u, schema.getFieldByName("bar").getProto().getNonGroup().getOffset());
} }
TEST(Encoding, Groups) { TEST(Encoding, Groups) {
...@@ -569,7 +569,7 @@ TEST(Encoding, UnionDefault) { ...@@ -569,7 +569,7 @@ TEST(Encoding, UnionDefault) {
{ {
auto field = reader.getUnnamed1(); auto field = reader.getUnnamed1();
EXPECT_EQ(test::TestUnnamedUnion::FOO, field.which()); EXPECT_EQ(test::TestUnnamedUnion::FOO, field.which());
EXPECT_EQ(123, field.getFoo()); EXPECT_EQ(123u, field.getFoo());
EXPECT_FALSE(field.hasBefore()); EXPECT_FALSE(field.hasBefore());
EXPECT_FALSE(field.hasAfter()); EXPECT_FALSE(field.hasAfter());
} }
...@@ -577,7 +577,7 @@ TEST(Encoding, UnionDefault) { ...@@ -577,7 +577,7 @@ TEST(Encoding, UnionDefault) {
{ {
auto field = reader.getUnnamed2(); auto field = reader.getUnnamed2();
EXPECT_EQ(test::TestUnnamedUnion::BAR, field.which()); EXPECT_EQ(test::TestUnnamedUnion::BAR, field.which());
EXPECT_EQ(321, field.getBar()); EXPECT_EQ(321u, field.getBar());
EXPECT_EQ("foo", field.getBefore()); EXPECT_EQ("foo", field.getBefore());
EXPECT_EQ("bar", field.getAfter()); EXPECT_EQ("bar", field.getAfter());
} }
......
...@@ -99,7 +99,7 @@ TEST(SchemaParser, Basic) { ...@@ -99,7 +99,7 @@ TEST(SchemaParser, Basic) {
auto barStruct = barSchema.getNested("Bar"); auto barStruct = barSchema.getNested("Bar");
auto barFields = barStruct.asStruct().getFields(); auto barFields = barStruct.asStruct().getFields();
ASSERT_EQ(4, barFields.size()); ASSERT_EQ(4u, barFields.size());
EXPECT_EQ("baz", barFields[0].getProto().getName()); EXPECT_EQ("baz", barFields[0].getProto().getName());
EXPECT_EQ(0x823456789abcdef1ull, getFieldTypeFileId(barFields[0])); EXPECT_EQ(0x823456789abcdef1ull, getFieldTypeFileId(barFields[0]));
EXPECT_EQ("corge", barFields[1].getProto().getName()); EXPECT_EQ("corge", barFields[1].getProto().getName());
......
...@@ -7,10 +7,16 @@ doit() { ...@@ -7,10 +7,16 @@ doit() {
"$@" "$@"
} }
if [ $# -gt 0 ]; then QUICK=
if [ "x$1" == "xtest" ]; then
: # nothing while [ $# -gt 0 ]; do
elif [ "x$1" == "xremote" ]; then case "$1" in
test )
;; # nothing
quick )
QUICK=quick
;;
remote )
if [ "$#" -lt 2 ]; then if [ "$#" -lt 2 ]; then
echo "usage: $0 remote HOST [COMMAND]" >&2 echo "usage: $0 remote HOST [COMMAND]" >&2
exit 1 exit 1
...@@ -24,11 +30,14 @@ if [ $# -gt 0 ]; then ...@@ -24,11 +30,14 @@ if [ $# -gt 0 ]; then
git push ssh://$HOST/~/tmp-test-capnp master:test git push ssh://$HOST/~/tmp-test-capnp master:test
ssh $HOST "cd tmp-test-capnp && git checkout test && ./super-test.sh $@ && cd .. && rm -rf tmp-test-capnp" ssh $HOST "cd tmp-test-capnp && git checkout test && ./super-test.sh $@ && cd .. && rm -rf tmp-test-capnp"
exit 0 exit 0
elif [ "x$1" == "xclang" ]; then ;;
clang )
export CXX=clang++ export CXX=clang++
elif [ "x$1" == "xgcc-4.8" ]; then ;;
gcc-4.8 )
export CXX=g++-4.8 export CXX=g++-4.8
elif [ "x$1" == "xkenton" ]; then ;;
kenton )
cat << "__EOF__" cat << "__EOF__"
========================================================================= =========================================================================
************************************************************************* *************************************************************************
...@@ -41,7 +50,7 @@ if [ $# -gt 0 ]; then ...@@ -41,7 +50,7 @@ if [ $# -gt 0 ]; then
************************************************************************* *************************************************************************
========================================================================= =========================================================================
__EOF__ __EOF__
$0 test $0 test $QUICK
$0 clean $0 clean
cat << "__EOF__" cat << "__EOF__"
========================================================================= =========================================================================
...@@ -55,7 +64,7 @@ __EOF__ ...@@ -55,7 +64,7 @@ __EOF__
************************************************************************* *************************************************************************
========================================================================= =========================================================================
__EOF__ __EOF__
$0 remote beat $0 remote beat $QUICK
cat << "__EOF__" cat << "__EOF__"
========================================================================= =========================================================================
************************************************************************* *************************************************************************
...@@ -68,7 +77,7 @@ __EOF__ ...@@ -68,7 +77,7 @@ __EOF__
************************************************************************* *************************************************************************
========================================================================= =========================================================================
__EOF__ __EOF__
$0 remote Kenton@flashman $0 remote Kenton@flashman $QUICK
cat << "__EOF__" cat << "__EOF__"
========================================================================= =========================================================================
************************************************************************* *************************************************************************
...@@ -81,7 +90,7 @@ __EOF__ ...@@ -81,7 +90,7 @@ __EOF__
************************************************************************* *************************************************************************
========================================================================= =========================================================================
__EOF__ __EOF__
$0 gcc-4.8 $0 gcc-4.8 $QUICK
$0 clean $0 clean
cat << "__EOF__" cat << "__EOF__"
========================================================================= =========================================================================
...@@ -95,7 +104,7 @@ __EOF__ ...@@ -95,7 +104,7 @@ __EOF__
************************************************************************* *************************************************************************
========================================================================= =========================================================================
__EOF__ __EOF__
$0 clang $0 clang $QUICK
$0 clean $0 clean
cat << "__EOF__" cat << "__EOF__"
========================================================================= =========================================================================
...@@ -110,7 +119,8 @@ __EOF__ ...@@ -110,7 +119,8 @@ __EOF__
========================================================================= =========================================================================
__EOF__ __EOF__
exit 0 exit 0
elif [ "x$1" == "xclean" ]; then ;;
clean )
rm -rf tmp-staging rm -rf tmp-staging
cd c++ cd c++
if [ -e Makefile ]; then if [ -e Makefile ]; then
...@@ -119,7 +129,8 @@ __EOF__ ...@@ -119,7 +129,8 @@ __EOF__
rm -f capnproto-*.tar.gz samples/addressbook samples/addressbook.capnp.c++ \ rm -f capnproto-*.tar.gz samples/addressbook samples/addressbook.capnp.c++ \
samples/addressbook.capnp.h samples/addressbook.capnp.h
exit 0 exit 0
elif [ "x$1" == "xhelp" ]; then ;;
help )
echo "usage: $0 [COMMAND]" echo "usage: $0 [COMMAND]"
echo "commands:" echo "commands:"
echo " test Runs tests (the default)." echo " test Runs tests (the default)."
...@@ -130,27 +141,36 @@ __EOF__ ...@@ -130,27 +141,36 @@ __EOF__
echo " clean Delete temporary files that may be left after failure." echo " clean Delete temporary files that may be left after failure."
echo " help Prints this help text." echo " help Prints this help text."
exit 0 exit 0
else ;;
* )
echo "unknown command: $1" >&2 echo "unknown command: $1" >&2
echo "try: $0 help" >&2 echo "try: $0 help" >&2
exit 1 exit 1
fi ;;
fi esac
shift
done
rm -rf tmp-staging
mkdir tmp-staging
STAGING=$PWD/tmp-staging STAGING=$PWD/tmp-staging
mkdir $STAGING/bin if [ "$QUICK" != quick ]; then
mkdir $STAGING/lib rm -rf "$STAGING"
export PATH=$STAGING/bin:$PATH mkdir "$STAGING"
export LD_LIBRARY_PATH=$STAGING/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} mkdir "$STAGING/bin"
mkdir "$STAGING/lib"
export PATH=$STAGING/bin:$PATH
export LD_LIBRARY_PATH=$STAGING/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
fi
if [ "$QUICK" = quick ]; then
echo "************************** QUICK TEST ***********************************"
fi
echo "=========================================================================" echo "========================================================================="
echo "Building c++" echo "Building c++"
echo "=========================================================================" echo "========================================================================="
if [ "x`uname`" == xDarwin ]; then if [ "x`uname`" = xDarwin ]; then
if [ ! -e ~/clang-3.2/bin/clang++ ]; then if [ ! -e ~/clang-3.2/bin/clang++ ]; then
echo "You need to put the clang-3.2 binaries in ~/clang-3.2." >&2 echo "You need to put the clang-3.2 binaries in ~/clang-3.2." >&2
exit 1 exit 1
...@@ -167,14 +187,19 @@ doit autoreconf -i ...@@ -167,14 +187,19 @@ doit autoreconf -i
doit ./configure --prefix="$STAGING" doit ./configure --prefix="$STAGING"
doit make -j6 check doit make -j6 check
if [ "$QUICK" = quick ]; then
make maintainer-clean
exit 0
fi
echo "=========================================================================" echo "========================================================================="
echo "Testing c++ install" echo "Testing c++ install"
echo "=========================================================================" echo "========================================================================="
doit make install doit make install
test "x$(which capnp)" == "x$STAGING/bin/capnp" test "x$(which capnp)" = "x$STAGING/bin/capnp"
test "x$(which capnpc-c++)" == "x$STAGING/bin/capnpc-c++" test "x$(which capnpc-c++)" = "x$STAGING/bin/capnpc-c++"
cd samples cd samples
doit capnp compile -oc++ addressbook.capnp -I"$STAGING"/include --no-standard-import doit capnp compile -oc++ addressbook.capnp -I"$STAGING"/include --no-standard-import
......
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