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

Fix GCC problems.

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