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,29 +7,38 @@ doit() { ...@@ -7,29 +7,38 @@ doit() {
"$@" "$@"
} }
if [ $# -gt 0 ]; then QUICK=
if [ "x$1" == "xtest" ]; then
: # nothing while [ $# -gt 0 ]; do
elif [ "x$1" == "xremote" ]; then case "$1" in
if [ "$#" -lt 2 ]; then test )
echo "usage: $0 remote HOST [COMMAND]" >&2 ;; # nothing
exit 1 quick )
fi QUICK=quick
HOST=$2 ;;
shift 2 remote )
echo "=========================================================================" if [ "$#" -lt 2 ]; then
echo "Pushing code to $HOST..." echo "usage: $0 remote HOST [COMMAND]" >&2
echo "=========================================================================" exit 1
ssh $HOST 'rm -rf tmp-test-capnp && mkdir tmp-test-capnp && git init tmp-test-capnp' fi
git push ssh://$HOST/~/tmp-test-capnp master:test HOST=$2
ssh $HOST "cd tmp-test-capnp && git checkout test && ./super-test.sh $@ && cd .. && rm -rf tmp-test-capnp" shift 2
exit 0 echo "========================================================================="
elif [ "x$1" == "xclang" ]; then echo "Pushing code to $HOST..."
export CXX=clang++ echo "========================================================================="
elif [ "x$1" == "xgcc-4.8" ]; then ssh $HOST 'rm -rf tmp-test-capnp && mkdir tmp-test-capnp && git init tmp-test-capnp'
export CXX=g++-4.8 git push ssh://$HOST/~/tmp-test-capnp master:test
elif [ "x$1" == "xkenton" ]; then ssh $HOST "cd tmp-test-capnp && git checkout test && ./super-test.sh $@ && cd .. && rm -rf tmp-test-capnp"
cat << "__EOF__" exit 0
;;
clang )
export CXX=clang++
;;
gcc-4.8 )
export CXX=g++-4.8
;;
kenton )
cat << "__EOF__"
========================================================================= =========================================================================
************************************************************************* *************************************************************************
_ _ ____ ____ ____ _ _ ____ ____ ____
...@@ -41,9 +50,9 @@ if [ $# -gt 0 ]; then ...@@ -41,9 +50,9 @@ if [ $# -gt 0 ]; then
************************************************************************* *************************************************************************
========================================================================= =========================================================================
__EOF__ __EOF__
$0 test $0 test $QUICK
$0 clean $0 clean
cat << "__EOF__" cat << "__EOF__"
========================================================================= =========================================================================
************************************************************************* *************************************************************************
___ ______ __ ____ _ ___ ______ __ ____ _
...@@ -55,8 +64,8 @@ __EOF__ ...@@ -55,8 +64,8 @@ __EOF__
************************************************************************* *************************************************************************
========================================================================= =========================================================================
__EOF__ __EOF__
$0 remote beat $0 remote beat $QUICK
cat << "__EOF__" cat << "__EOF__"
========================================================================= =========================================================================
************************************************************************* *************************************************************************
____ _ ____ _
...@@ -68,8 +77,8 @@ __EOF__ ...@@ -68,8 +77,8 @@ __EOF__
************************************************************************* *************************************************************************
========================================================================= =========================================================================
__EOF__ __EOF__
$0 remote Kenton@flashman $0 remote Kenton@flashman $QUICK
cat << "__EOF__" cat << "__EOF__"
========================================================================= =========================================================================
************************************************************************* *************************************************************************
____ ____ ____ _ _ ___ ____ ____ ____ _ _ ___
...@@ -81,9 +90,9 @@ __EOF__ ...@@ -81,9 +90,9 @@ __EOF__
************************************************************************* *************************************************************************
========================================================================= =========================================================================
__EOF__ __EOF__
$0 gcc-4.8 $0 gcc-4.8 $QUICK
$0 clean $0 clean
cat << "__EOF__" cat << "__EOF__"
========================================================================= =========================================================================
************************************************************************* *************************************************************************
_ _ ____ _ _ _ ____ _
...@@ -95,9 +104,9 @@ __EOF__ ...@@ -95,9 +104,9 @@ __EOF__
************************************************************************* *************************************************************************
========================================================================= =========================================================================
__EOF__ __EOF__
$0 clang $0 clang $QUICK
$0 clean $0 clean
cat << "__EOF__" cat << "__EOF__"
========================================================================= =========================================================================
************************************************************************* *************************************************************************
____ _ _ ___ ____ ___ _____ ____ _ _ ___ ____ ___ _____
...@@ -109,48 +118,59 @@ __EOF__ ...@@ -109,48 +118,59 @@ __EOF__
************************************************************************* *************************************************************************
========================================================================= =========================================================================
__EOF__ __EOF__
exit 0 exit 0
elif [ "x$1" == "xclean" ]; then ;;
rm -rf tmp-staging clean )
cd c++ rm -rf tmp-staging
if [ -e Makefile ]; then cd c++
doit make maintainer-clean if [ -e Makefile ]; then
fi doit make maintainer-clean
rm -f capnproto-*.tar.gz samples/addressbook samples/addressbook.capnp.c++ \ fi
samples/addressbook.capnp.h rm -f capnproto-*.tar.gz samples/addressbook samples/addressbook.capnp.c++ \
exit 0 samples/addressbook.capnp.h
elif [ "x$1" == "xhelp" ]; then exit 0
echo "usage: $0 [COMMAND]" ;;
echo "commands:" help )
echo " test Runs tests (the default)." echo "usage: $0 [COMMAND]"
echo " clang Runs tests using Clang compiler." echo "commands:"
echo " gcc-4.8 Runs tests using gcc-4.8." echo " test Runs tests (the default)."
echo " remote HOST Runs tests on HOST via SSH." echo " clang Runs tests using Clang compiler."
echo " kenton Kenton's meta-test (uses hosts on Kenton's network)." echo " gcc-4.8 Runs tests using gcc-4.8."
echo " clean Delete temporary files that may be left after failure." echo " remote HOST Runs tests on HOST via SSH."
echo " help Prints this help text." echo " kenton Kenton's meta-test (uses hosts on Kenton's network)."
exit 0 echo " clean Delete temporary files that may be left after failure."
else echo " help Prints this help text."
echo "unknown command: $1" >&2 exit 0
echo "try: $0 help" >&2 ;;
exit 1 * )
fi echo "unknown command: $1" >&2
fi echo "try: $0 help" >&2
exit 1
;;
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