Commit a227f743 authored by Kenton Varda's avatar Kenton Varda

Make sure generated code compiles cleanly even with pedantic warnings, since…

Make sure generated code compiles cleanly even with pedantic warnings, since some people enable those.
parent 60e1a79d
......@@ -1270,21 +1270,28 @@ private:
auto schemaDef = kj::strTree(
"static const ::capnp::_::AlignedData<", rawSchema.size(), "> b_", hexId, " = {\n"
" {", kj::mv(schemaLiteral), " }\n"
"};\n"
"static const ::capnp::_::RawSchema* const d_", hexId, "[] = {\n",
KJ_MAP(depId, deps) {
return kj::strTree(" &s_", kj::hex(depId), ",\n");
},
"};\n"
"static const uint16_t m_", hexId, "[] = {",
kj::StringTree(KJ_MAP(index, membersByName) { return kj::strTree(index); }, ", "),
"};\n"
"static const uint16_t i_", hexId, "[] = {",
kj::StringTree(KJ_MAP(index, membersByDiscrim) { return kj::strTree(index); }, ", "),
"};\n"
"};\n",
deps.size() == 0 ? kj::strTree() : kj::strTree(
"static const ::capnp::_::RawSchema* const d_", hexId, "[] = {\n",
KJ_MAP(depId, deps) {
return kj::strTree(" &s_", kj::hex(depId), ",\n");
},
"};\n"),
membersByName.size() == 0 ? kj::strTree() : kj::strTree(
"static const uint16_t m_", hexId, "[] = {",
kj::StringTree(KJ_MAP(index, membersByName) { return kj::strTree(index); }, ", "),
"};\n"),
membersByDiscrim.size() == 0 ? kj::strTree() : kj::strTree(
"static const uint16_t i_", hexId, "[] = {",
kj::StringTree(KJ_MAP(index, membersByDiscrim) { return kj::strTree(index); }, ", "),
"};\n"),
"const ::capnp::_::RawSchema s_", hexId, " = {\n"
" 0x", hexId, ", b_", hexId, ".words, ", rawSchema.size(), ", d_", hexId, ", m_", hexId, ",\n"
" ", deps.size(), ", ", membersByName.size(), ", i_", hexId, ", nullptr, nullptr\n"
" 0x", hexId, ", b_", hexId, ".words, ", rawSchema.size(), ", ",
deps.size() == 0 ? kj::strTree("nullptr") : kj::strTree("d_", hexId), ", ",
membersByName.size() == 0 ? kj::strTree("nullptr") : kj::strTree("m_", hexId), ",\n",
" ", deps.size(), ", ", membersByName.size(), ", ",
membersByDiscrim.size() == 0 ? kj::strTree("nullptr") : kj::strTree("i_", hexId),
", nullptr, nullptr\n"
"};\n");
switch (proto.which()) {
......
......@@ -613,8 +613,8 @@ public:
inline Builder(Builder& other) { memcpy(this, &other, sizeof(*this)); }
inline Builder(Builder&& other) { memcpy(this, &other, sizeof(*this)); }
inline Builder& operator=(Builder& other) { memcpy(this, &other, sizeof(*this)); }
inline Builder& operator=(Builder&& other) { memcpy(this, &other, sizeof(*this)); }
inline Builder& operator=(Builder& other) { memcpy(this, &other, sizeof(*this)); return *this; }
inline Builder& operator=(Builder&& other) { memcpy(this, &other, sizeof(*this)); return *this; }
static_assert(__has_trivial_copy(StructSchema) && __has_trivial_copy(ListSchema),
"Assumptions made here do not hold.");
// Hack: We know this type is trivially constructable but the use of DisallowConstCopy causes
......
......@@ -322,7 +322,7 @@ inline constexpr uint64_t typeId() { return _::TypeId_<T>::typeId; }
}
#define CAPNP_DEFINE_ENUM(type) \
constexpr Kind Kind_<type>::kind; \
constexpr uint64_t TypeId_<type>::typeId;
constexpr uint64_t TypeId_<type>::typeId
#define CAPNP_DECLARE_STRUCT(type, id, dataWordSize, pointerCount, preferredElementEncoding) \
template <> struct Kind_<type> { static constexpr Kind kind = Kind::STRUCT; }; \
......@@ -337,7 +337,7 @@ inline constexpr uint64_t typeId() { return _::TypeId_<T>::typeId; }
#define CAPNP_DEFINE_STRUCT(type) \
constexpr Kind Kind_<type>::kind; \
constexpr StructSize StructSize_<type>::value; \
constexpr uint64_t TypeId_<type>::typeId;
constexpr uint64_t TypeId_<type>::typeId
#define CAPNP_DECLARE_UNION(type, parentType, memberIndex) \
template <> struct Kind_<type> { static constexpr Kind kind = Kind::UNION; }; \
......@@ -345,7 +345,7 @@ inline constexpr uint64_t typeId() { return _::TypeId_<T>::typeId; }
template <> struct UnionParentType_<type> { typedef parentType Type; }
#define CAPNP_DEFINE_UNION(type) \
constexpr Kind Kind_<type>::kind; \
constexpr uint UnionMemberIndex_<type>::value;
constexpr uint UnionMemberIndex_<type>::value
#define CAPNP_DECLARE_INTERFACE(type, id) \
template <> struct Kind_<type> { static constexpr Kind kind = Kind::INTERFACE; }; \
......@@ -355,6 +355,6 @@ inline constexpr uint64_t typeId() { return _::TypeId_<T>::typeId; }
}
#define CAPNP_DEFINE_INTERFACE(type) \
constexpr Kind Kind_<type>::kind; \
constexpr uint64_t TypeId_<type>::typeId;
constexpr uint64_t TypeId_<type>::typeId
#endif // CAPNP_GENERATED_HEADER_SUPPORT_H_
......@@ -193,7 +193,7 @@ case ${CXX:-g++} in
# There's an unused private field in gtest.
export CXXFLAGS="$CXXFLAGS -Wno-unused-private-field"
;;
*g++* )
g++* | *-g++* )
if (${CXX:-g++} --version | grep -q ' 4[.]8'); then
# 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
......@@ -211,6 +211,11 @@ doit autoreconf -i
doit ./configure --prefix="$STAGING"
doit make -j6 check
# Verify that generated code compiles with pedantic warnings. Make sure to treat capnp headers
# as system headers so warnings in them are ignored.
doit ${CXX:-g++} -isystem src -std=c++11 -fno-permissive -pedantic -Wall -Wextra -Werror \
-c src/capnp/test.capnp.c++ -o /dev/null
if [ "$QUICK" = quick ]; then
make maintainer-clean
exit 0
......
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