fix pedantic warnings

This commit is contained in:
Joao Paulo Magalhaes
2019-12-24 11:45:45 +01:00
parent 3dc1f664d6
commit 9904f1eb3a
48 changed files with 331 additions and 166 deletions

View File

@@ -3,7 +3,7 @@ ryml_setup_benchmarking(ryml)
# -----------------------------------------------------------------------------
# json libs that will be compared with ryml (and the other yaml libs)
set(_ed ${CMAKE_CURRENT_BINARY_DIR}/extern) # casual ryml extern dir (these projects are not part of ryml and are downloaded and compiled on the fly)
set(_ed ${CMAKE_CURRENT_BINARY_DIR}/ext) # casual ryml extern dir (these projects are not part of ryml and are downloaded and compiled on the fly)
# jsoncpp needs to be compiled
c4_override(JSONCPP_WITH_TESTS OFF)
@@ -32,16 +32,18 @@ ryml_require_subproject(nlohmann_json REMOTE
GIT_TAG master)
# rapidjson is header only
ryml_download_remote_proj(rapidjson ${_ed}/rapidjson
set(rapidjson_dir ${_ed}/rapidjson)
ryml_download_remote_proj(rapidjson rapidjson_dir
GIT_REPOSITORY https://github.com/Tencent/rapidjson
GIT_TAG version1.1.0)
set(RYML_RAPIDJSON_INC_DIR ${_ed}/rapidjson/src/include)
set(RYML_RAPIDJSON_INC_DIR ${rapidjson_dir}/include)
# sajson is header only
ryml_download_remote_proj(sajson ${_ed}/sajson
set(sajson_dir ${_ed}/sajson)
ryml_download_remote_proj(sajson sajson_dir
GIT_REPOSITORY https://github.com/chadaustin/sajson
GIT_TAG master)
set(RYML_SAJSON_INC_DIR ${_ed}/sajson/src/include)
set(RYML_SAJSON_INC_DIR ${sajson_dir}/include)
# -----------------------------------------------------------------------------

View File

@@ -1,19 +1,69 @@
#include <benchmark/benchmark.h>
#include <ryml.hpp>
#include <ryml_std.hpp>
#include <c4/fs/fs.hpp>
#include "../test/libyaml.hpp"
#include <vector>
#include <iostream>
#include <yaml-cpp/yaml.h>
#include <benchmark/benchmark.h>
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4100) // sajson.h(1313,41): warning C4100: 'input_document_size_in_bytes': unreferenced formal parameter
# pragma warning(disable : 4127) // conditional expression is constant
# pragma warning(disable : 4200) // sajson.h(209,28): warning C4200: nonstandard extension used: zero-sized array in struct/union
# pragma warning(disable : 4244) // sajson.h(2295,26): warning C4244: '=': conversion from 'unsigned int' to 'char', possible loss of data
# pragma warning(disable : 4389) // '==': signed/unsigned mismatch
# pragma warning(disable : 4996) // warning C4996: 'Json::Reader': Use CharReader and CharReaderBuilder instead.
#elif defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunused-parameter"
# pragma clang diagnostic ignored "-Wc99-extensions"
# pragma clang diagnostic ignored "-Wfloat-equal"
# pragma clang diagnostic ignored "-Wshadow"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wshadow"
# pragma GCC diagnostic ignored "-Wunused-parameter"
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
# pragma GCC diagnostic ignored "-Wfloat-equal"
# pragma GCC diagnostic ignored "-Wpedantic"
# if __GNUC__ >= 8
# pragma GCC diagnostic ignored "-Wclass-memaccess" // rapidjson/document.h:1952:24
# endif
#endif
#include <rapidjson/document.h>
#include <sajson.h>
#include <json/json.h>
#include <nlohmann/json.hpp>
#include <yaml-cpp/yaml.h>
#if defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif
namespace bm = benchmark;
// now for our code
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4996) // warning C4996: 'Json::Reader': Use CharReader and CharReaderBuilder instead.
#elif defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# pragma clang diagnostic ignored "-Wunused-variable"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
# pragma GCC diagnostic ignored "-Wunused-variable"
#endif
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@@ -98,14 +148,14 @@ struct BmCase
*
* don't declare the case as static as there's no guarantee the allocator's
* lifetime starts before and ends after the case's lifetime */
static BmCase * C4_RESTRICT c = nullptr;
static BmCase * C4_RESTRICT s_bm_case = nullptr;
int main(int argc, char** argv)
{
BmCase fixture;
c = &fixture;
c->run(argc, argv);
s_bm_case = &fixture;
s_bm_case->run(argc, argv);
}
@@ -114,59 +164,59 @@ int main(int argc, char** argv)
//-----------------------------------------------------------------------------
#define ONLY_FOR_JSON \
if(!c->is_json) { st.SkipWithError("not a json file"); return; }
if(!s_bm_case->is_json) { st.SkipWithError("not a json file"); return; }
void rapidjson_ro(bm::State& st)
{
const char *src = c->src.data();
const char *src = s_bm_case->src.data();
for(auto _ : st)
{
ONLY_FOR_JSON;
rapidjson::Document doc;
doc.Parse(src);
}
st.SetBytesProcessed(st.iterations() * c->src.size());
st.SetBytesProcessed(st.iterations() * s_bm_case->src.size());
}
void rapidjson_rw(bm::State& st)
{
char *src = c->in_place.data();
char *src = s_bm_case->in_place.data();
for(auto _ : st)
{
ONLY_FOR_JSON;
c->prepare(st, kResetInPlace);
s_bm_case->prepare(st, kResetInPlace);
rapidjson::Document doc;
doc.ParseInsitu(src);
}
st.SetBytesProcessed(st.iterations() * c->src.size());
st.SetBytesProcessed(st.iterations() * s_bm_case->src.size());
}
void sajson_ro(bm::State& st)
{
sajson::string src = {c->src.data(), c->src.size()};
sajson::string src = {s_bm_case->src.data(), s_bm_case->src.size()};
for(auto _ : st)
{
ONLY_FOR_JSON;
sajson::document document = sajson::parse(sajson::dynamic_allocation(), src);
}
st.SetBytesProcessed(st.iterations() * c->src.size());
st.SetBytesProcessed(st.iterations() * s_bm_case->src.size());
}
void sajson_rw(bm::State& st)
{
sajson::mutable_string_view src = {c->in_place.size(), c->in_place.data()};
sajson::mutable_string_view src = {s_bm_case->in_place.size(), s_bm_case->in_place.data()};
for(auto _ : st)
{
ONLY_FOR_JSON;
c->prepare(st, kResetInPlace);
s_bm_case->prepare(st, kResetInPlace);
sajson::document document = sajson::parse(sajson::dynamic_allocation(), src);
}
st.SetBytesProcessed(st.iterations() * c->src.size());
st.SetBytesProcessed(st.iterations() * s_bm_case->src.size());
}
void jsoncpp_ro(bm::State& st)
{
const char *b = &c->src.front(), *e = &c->src.back();
const char *b = &s_bm_case->src.front(), *e = &s_bm_case->src.back();
for(auto _ : st)
{
ONLY_FOR_JSON;
@@ -174,107 +224,107 @@ void jsoncpp_ro(bm::State& st)
Json::Reader reader;
reader.parse(b, e, root);
}
st.SetBytesProcessed(st.iterations() * c->src.size());
st.SetBytesProcessed(st.iterations() * s_bm_case->src.size());
}
void nlohmann_json_ro(bm::State& st)
{
const char* src = c->src.data();
const char* src = s_bm_case->src.data();
for(auto _ : st)
{
ONLY_FOR_JSON;
auto root = nlohmann::json::parse(src);
}
st.SetBytesProcessed(st.iterations() * c->src.size());
st.SetBytesProcessed(st.iterations() * s_bm_case->src.size());
}
void yamlcpp_ro(bm::State& st)
{
const char* src = c->src.data();
const char* src = s_bm_case->src.data();
for(auto _ : st)
{
YAML::Node node = YAML::Load(src);
}
st.SetBytesProcessed(st.iterations() * c->src.size());
st.SetBytesProcessed(st.iterations() * s_bm_case->src.size());
}
void libyaml_ro(bm::State& st)
{
c4::csubstr src = c4::to_csubstr(c->src.data());
c4::csubstr src = c4::to_csubstr(s_bm_case->src.data());
for(auto _ : st)
{
c4::yml::LibyamlParser p;
c4::yml::Tree t;
p.parse(&t, src);
}
st.SetBytesProcessed(st.iterations() * c->src.size());
st.SetBytesProcessed(st.iterations() * s_bm_case->src.size());
}
void libyaml_ro_reuse(bm::State& st)
{
c4::csubstr src = c4::to_csubstr(c->src.data());
c4::csubstr src = c4::to_csubstr(s_bm_case->src.data());
for(auto _ : st)
{
c4::yml::LibyamlParser libyaml_parser;
c->prepare(st, kClearTree|kClearTreeArena);
libyaml_parser.parse(&c->libyaml_tree, src);
s_bm_case->prepare(st, kClearTree|kClearTreeArena);
libyaml_parser.parse(&s_bm_case->libyaml_tree, src);
}
st.SetBytesProcessed(st.iterations() * c->src.size());
st.SetBytesProcessed(st.iterations() * s_bm_case->src.size());
}
void ryml_ro(bm::State& st)
{
size_t sz = 0;
c4::csubstr src = c4::to_csubstr(c->src);
c4::csubstr src = c4::to_csubstr(s_bm_case->src);
for(auto _ : st)
{
ryml::Tree tree = ryml::parse(c->filename, src);
ryml::Tree tree = ryml::parse(s_bm_case->filename, src);
sz = tree.size();
}
st.SetItemsProcessed(st.iterations() * sz);
st.SetBytesProcessed(st.iterations() * c->src.size());
st.SetBytesProcessed(st.iterations() * s_bm_case->src.size());
}
void ryml_rw(bm::State& st)
{
size_t sz = 0;
c4::substr src = c4::to_substr(c->in_place);
c4::substr src = c4::to_substr(s_bm_case->in_place);
for(auto _ : st)
{
c->prepare(st, kResetInPlace);
ryml::Tree tree = ryml::parse(c->filename, src);
s_bm_case->prepare(st, kResetInPlace);
ryml::Tree tree = ryml::parse(s_bm_case->filename, src);
sz = tree.size();
}
st.SetItemsProcessed(st.iterations() * sz);
st.SetBytesProcessed(st.iterations() * c->src.size());
st.SetBytesProcessed(st.iterations() * s_bm_case->src.size());
}
void ryml_ro_reuse(bm::State& st)
{
size_t sz = 0;
c4::csubstr src = c4::to_csubstr(c->src);
c4::csubstr src = c4::to_csubstr(s_bm_case->src);
for(auto _ : st)
{
c->prepare(st, kClearTree|kClearTreeArena);
c->ryml_parser.parse(c->filename, src, &c->ryml_tree);
sz = c->ryml_tree.size();
s_bm_case->prepare(st, kClearTree|kClearTreeArena);
s_bm_case->ryml_parser.parse(s_bm_case->filename, src, &s_bm_case->ryml_tree);
sz = s_bm_case->ryml_tree.size();
}
st.SetItemsProcessed(st.iterations() * sz);
st.SetBytesProcessed(st.iterations() * c->src.size());
st.SetBytesProcessed(st.iterations() * s_bm_case->src.size());
}
void ryml_rw_reuse(bm::State& st)
{
size_t sz = 0;
c4::substr src = c4::to_substr(c->in_place);
c4::substr src = c4::to_substr(s_bm_case->in_place);
for(auto _ : st)
{
c->prepare(st, kResetInPlace|kClearTree|kClearTreeArena);
c->ryml_parser.parse(c->filename, c4::to_substr(c->in_place), &c->ryml_tree);
sz = c->ryml_tree.size();
s_bm_case->prepare(st, kResetInPlace|kClearTree|kClearTreeArena);
s_bm_case->ryml_parser.parse(s_bm_case->filename, src, &s_bm_case->ryml_tree);
sz = s_bm_case->ryml_tree.size();
}
st.SetItemsProcessed(st.iterations() * sz);
st.SetBytesProcessed(st.iterations() * c->src.size());
st.SetBytesProcessed(st.iterations() * s_bm_case->src.size());
}
BENCHMARK(rapidjson_ro);
@@ -290,3 +340,11 @@ BENCHMARK(ryml_ro);
BENCHMARK(ryml_rw);
BENCHMARK(ryml_ro_reuse);
BENCHMARK(ryml_rw_reuse);
#if defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif

2
extern/c4core vendored

View File

@@ -3,6 +3,12 @@
#include "c4/yml/tree.hpp"
#ifdef __clang__
# pragma clang diagnostic push
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wtype-limits" // error: comparison of unsigned expression >= 0 is always true
#endif
namespace c4 {
namespace yml {
@@ -145,7 +151,7 @@ inline void check_free_list(Tree const& t)
C4_CHECK(t.m_free_tail >= 0 && t.m_free_tail < t.m_cap)
auto const& head = *t._p(t.m_free_head);
auto const& tail = *t._p(t.m_free_tail);
//auto const& tail = *t._p(t.m_free_tail);
//C4_CHECK(head.m_prev_sibling == NONE);
//C4_CHECK(tail.m_next_sibling == NONE);
@@ -171,14 +177,19 @@ inline void check_free_list(Tree const& t)
inline void check_arena(Tree const& t)
{
C4_CHECK(t.m_arena.len == 0 || t.m_arena_pos >= 0 && t.m_arena_pos < t.m_arena.len);
C4_CHECK(t.m_arena.len == 0 || (t.m_arena_pos >= 0 && t.m_arena_pos < t.m_arena.len));
C4_CHECK(t.arena_size() == t.m_arena_pos);
C4_CHECK(t.arena_slack() == t.m_arena.len - t.m_arena_pos);
C4_CHECK(t.arena_slack() + t.m_arena_pos == t.m_arena.len);
}
} /* namespace yml */
} /* namespace c4 */
#ifdef __clang__
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif
#endif /* C4_YML_DETAIL_CHECKS_HPP_ */

View File

@@ -36,8 +36,8 @@ public:
constexpr static bool is_contiguous() { return true; }
stack() : m_stack(m_buf), m_size(0), m_capacity(N), m_alloc() {}
stack(Allocator const& c) : m_stack(m_buf), m_size(0), m_capacity(N), m_alloc(c)
stack() : m_buf(), m_stack(m_buf), m_size(0), m_capacity(N), m_alloc() {}
stack(Allocator const& c) : m_buf(), m_stack(m_buf), m_size(0), m_capacity(N), m_alloc(c)
{
}
~stack()
@@ -120,17 +120,18 @@ public:
C4_ALWAYS_INLINE T const& C4_RESTRICT operator[](size_t i) const { C4_ASSERT(i >= 0 && i < m_size); return m_stack[i]; }
C4_ALWAYS_INLINE T & C4_RESTRICT operator[](size_t i) { C4_ASSERT(i >= 0 && i < m_size); return m_stack[i]; }
using iterator = T * C4_RESTRICT;
using const_iterator = T const * C4_RESTRICT;
public:
using iterator = T *;
using const_iterator = T const *;
iterator begin() { return m_stack; }
iterator end () { return m_stack + m_size; }
const_iterator begin() const { return m_stack; }
const_iterator end () const { return m_stack + m_size; }
const_iterator begin() const { return (const_iterator)m_stack; }
const_iterator end () const { return (const_iterator)m_stack + m_size; }
public:
void _free();
void _cp(stack const* C4_RESTRICT that);
void _mv(stack * that);

View File

@@ -1179,8 +1179,8 @@ bool Parser::_handle_top()
// use the full line, as the following tokens can appear only at top level
C4_ASSERT(rem == m_state->line_contents.stripped
||
m_state->indref > 0 && rem.begin() > m_state->line_contents.stripped.begin() &&
m_state->indref == (rem.begin() - m_state->line_contents.stripped.begin()));
(m_state->indref > 0 && (rem.begin() > m_state->line_contents.stripped.begin() &&
m_state->indref + m_state->line_contents.stripped.begin() == rem.begin())));
if(m_state->indref == 0)
{
rem = m_state->line_contents.stripped;

View File

@@ -208,7 +208,24 @@ private:
LineContents line_contents;
size_t indref;
State() { memset(this, 0, sizeof(*this)); }
State()
{
#ifdef __clang__
# pragma clang diagnostic push
//# pragma clang diagnostic ignored "-Wgnu-inline-cpp-without-extern" // debugbreak/debugbreak.h:50:16: error: 'gnu_inline' attribute without 'extern' in C++ treated as externally available, this changed in Clang 10 [-Werror,-Wgnu-inline-cpp-without-extern]
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# if __GNUC__>= 8
# pragma GCC diagnostic ignored "-Wclass-memaccess" // error: void* memset(void*, int, size_t) clearing an object of type class c4::yml::Tree with no trivial copy-assignment; use assignment or value-initialization instead
# endif
#endif
memset(this, 0, sizeof(*this));
#ifdef __clang__
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif
}
void reset(const char *file, size_t node_id_)
{
flags = RUNK|RTOP;

View File

@@ -134,6 +134,17 @@ void Tree::_free()
_clear();
}
#ifdef __clang__
# pragma clang diagnostic push
//# pragma clang diagnostic ignored "-Wgnu-inline-cpp-without-extern" // debugbreak/debugbreak.h:50:16: error: 'gnu_inline' attribute without 'extern' in C++ treated as externally available, this changed in Clang 10 [-Werror,-Wgnu-inline-cpp-without-extern]
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# if __GNUC__>= 8
# pragma GCC diagnostic ignored "-Wclass-memaccess" // error: void* memset(void*, int, size_t) clearing an object of type class c4::yml::Tree with no trivial copy-assignment; use assignment or value-initialization instead
# endif
#endif
void Tree::_clear()
{
memset(this, 0, sizeof(*this));
@@ -174,6 +185,7 @@ void Tree::_relocate(substr const& next_arena)
}
}
//-----------------------------------------------------------------------------
void Tree::reserve(size_t cap)
{
@@ -204,8 +216,8 @@ void Tree::reserve(size_t cap)
m_free_head = first;
m_free_tail = cap-1;
}
C4_ASSERT(m_free_head == NONE || m_free_head >= 0 && m_free_head < cap);
C4_ASSERT(m_free_tail == NONE || m_free_tail >= 0 && m_free_tail < cap);
C4_ASSERT(m_free_head == NONE || (m_free_head >= 0 && m_free_head < cap));
C4_ASSERT(m_free_tail == NONE || (m_free_tail >= 0 && m_free_tail < cap));
if( ! m_size)
{
@@ -214,6 +226,7 @@ void Tree::reserve(size_t cap)
}
}
//-----------------------------------------------------------------------------
void Tree::clear()
{
@@ -240,6 +253,7 @@ void Tree::_claim_root()
_set_hierarchy(r, NONE, NONE);
}
//-----------------------------------------------------------------------------
void Tree::_clear_range(size_t first, size_t num)
{
@@ -256,6 +270,13 @@ void Tree::_clear_range(size_t first, size_t num)
m_buf[first + num - 1].m_next_sibling = NONE;
}
#ifdef __clang__
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif
//-----------------------------------------------------------------------------
void Tree::_release(size_t i)
{
@@ -1009,7 +1030,7 @@ struct ReferenceResolver
void _store_anchors_and_refs(size_t n)
{
if(t->is_key_ref(n) || t->is_val_ref(n) || t->has_key(n) && t->key(n) == "<<")
if(t->is_key_ref(n) || t->is_val_ref(n) || (t->has_key(n) && t->key(n) == "<<"))
{
if(t->is_seq(n))
{

View File

@@ -135,6 +135,8 @@ public:
void rem(NodeType_e t) { type = (NodeType_e)(type & ~t); }
void rem(type_bits t) { type = (NodeType_e)(type & ~t); }
void clear() { type = NOTYPE; }
public:
bool is_stream() const { return ((type & STREAM) == STREAM) != 0; }
@@ -233,7 +235,9 @@ public:
void clear()
{
memset(this, 0, sizeof(*this));
type.clear();
key.clear();
val.clear();
}
void _add_flags(type_bits more_flags=0)
@@ -718,7 +722,7 @@ public:
inline operator bool() const { return target != NONE; }
lookup_result() : target(NONE), closest(NONE), path_pos(0), path() {}
lookup_result(csubstr path, size_t start) : target(NONE), closest(start), path_pos(0), path(path) {}
lookup_result(csubstr path_, size_t start) : target(NONE), closest(start), path_pos(0), path(path_) {}
csubstr resolved() const;
csubstr unresolved() const;

View File

@@ -9,6 +9,16 @@
#include <gtest/gtest.h>
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4389) // signed/unsigned mismatch
#elif defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
#endif
namespace foo {
template<class T>
@@ -497,7 +507,7 @@ TEST(NodeScalar, ctor__untagged)
{
{
const char sarr[] = "foo";
const char *sptr = "foo"; size_t sptrlen = 3;
const char *sptr = "foo";
csubstr ssp = "foo";
for(auto s : {NodeScalar(sarr), NodeScalar(to_csubstr(sptr)), NodeScalar(ssp)})
@@ -516,7 +526,7 @@ TEST(NodeScalar, ctor__untagged)
{
const char sarr[] = "foo3";
const char *sptr = "foo3"; size_t sptrlen = 4;
const char *sptr = "foo3";
csubstr ssp = "foo3";
for(auto s : {NodeScalar(sarr), NodeScalar(to_csubstr(sptr)), NodeScalar(ssp)})
@@ -549,8 +559,8 @@ TEST(NodeScalar, ctor__tagged)
{
const char sarr[] = "foo", tarr[] = "!!str";
const char *sptr = "foo"; size_t sptrlen = 3;
const char *tptr = "!!str"; size_t tptrlen = 5;
const char *sptr = "foo";
const char *tptr = "!!str";
csubstr ssp = "foo", tsp = "!!str";
for(auto s : ilist{
@@ -622,8 +632,8 @@ TEST(NodeScalar, ctor__tagged)
{
const char sarr[] = "foo3", tarr[] = "!!str+++";
const char *sptr = "foo3"; size_t sptrlen = 4;
const char *tptr = "!!str+++"; size_t tptrlen = 8;
const char *sptr = "foo3";
const char *tptr = "!!str+++";
csubstr ssp = "foo3", tsp = "!!str+++";
for(auto s : ilist{
@@ -1461,10 +1471,18 @@ a:
//-------------------------------------------
// this is needed to use the test case library
Case const* get_case(csubstr name)
Case const* get_case(csubstr /*name*/)
{
return nullptr;
}
} // namespace yml
} // namespace c4
#if defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif

View File

@@ -219,7 +219,7 @@ TEST(general, json_stream_operator)
//-------------------------------------------
// this is needed to use the test case library
Case const* get_case(csubstr name)
Case const* get_case(csubstr /*name*/)
{
return nullptr;
}

View File

@@ -259,7 +259,7 @@ another: val
)
}
INSTANTIATE_GROUP(BLOCK_FOLDED);
INSTANTIATE_GROUP(BLOCK_FOLDED)
} // namespace yml
} // namespace c4

View File

@@ -328,7 +328,7 @@ another: val
}
INSTANTIATE_GROUP(BLOCK_LITERAL);
INSTANTIATE_GROUP(BLOCK_LITERAL)
} // namespace yml
} // namespace c4

View File

@@ -185,7 +185,7 @@ R"(? >-
)
}
INSTANTIATE_GROUP(COMPLEX_KEY);
INSTANTIATE_GROUP(COMPLEX_KEY)
} // namespace yml
} // namespace c4

View File

@@ -114,7 +114,7 @@ that has multiple lines
)
}
INSTANTIATE_GROUP(DOUBLE_QUOTED);
INSTANTIATE_GROUP(DOUBLE_QUOTED)
} // namespace yml
} // namespace c4

View File

@@ -42,7 +42,7 @@ R"(---
);
}
INSTANTIATE_GROUP(EMPTY_DOC);
INSTANTIATE_GROUP(EMPTY_DOC)
} // namespace yml
} // namespace c4

View File

@@ -25,7 +25,7 @@ C("empty0-multiline-with-comments", R"(
);
}
INSTANTIATE_GROUP(EMPTY_FILE);
INSTANTIATE_GROUP(EMPTY_FILE)
} // namespace yml
} // namespace c4

View File

@@ -38,7 +38,7 @@ R"({
);
}
INSTANTIATE_GROUP(EMPTY_MAP);
INSTANTIATE_GROUP(EMPTY_MAP)
} // namespace yml
} // namespace c4

View File

@@ -36,7 +36,7 @@ R"([
);
}
INSTANTIATE_GROUP(EMPTY_SEQ);
INSTANTIATE_GROUP(EMPTY_SEQ)
} // namespace yml
} // namespace c4

View File

@@ -94,7 +94,7 @@ L{
)
}
INSTANTIATE_GROUP(GENERIC_MAP);
INSTANTIATE_GROUP(GENERIC_MAP)
} // namespace yml
} // namespace c4

View File

@@ -49,7 +49,7 @@ R"(
)
}
INSTANTIATE_GROUP(GENERIC_SEQ);
INSTANTIATE_GROUP(GENERIC_SEQ)
} // namespace yml
} // namespace c4

View File

@@ -208,7 +208,7 @@ N(L{N("Yt3ymqZXzLY", L{N("0.mp4"), N("1.mp4"), N("2.mp4"), N("3.mp4")})}),
)
}
INSTANTIATE_GROUP(GITHUB_ISSUES);
INSTANTIATE_GROUP(GITHUB_ISSUES)
} // namespace yml
} // namespace c4

View File

@@ -334,7 +334,7 @@ L{
)
}
INSTANTIATE_GROUP(INDENTATION);
INSTANTIATE_GROUP(INDENTATION)
} // namespace yml
} // namespace c4

View File

@@ -73,7 +73,7 @@ public:
void _do_parse()
{
bool done = false;
bool doc_had_scalars = false;
//bool doc_had_scalars = false;
csubstr prev_scalar;
while( ! done)
{
@@ -150,7 +150,7 @@ case YAML_ ## _ev ## _EVENT: \
prev_scalar = val;
}
}
doc_had_scalars = true;
//doc_had_scalars = true;
break;
}
_c4_handle_case(DOCUMENT_START)

View File

@@ -86,7 +86,7 @@ L{
)
}
INSTANTIATE_GROUP(MAP_OF_SEQ);
INSTANTIATE_GROUP(MAP_OF_SEQ)
} // namespace yml
} // namespace c4

View File

@@ -76,7 +76,7 @@ send_to:
)
}
INSTANTIATE_GROUP(NESTED_MAPX2);
INSTANTIATE_GROUP(NESTED_MAPX2)
} // namespace yml
} // namespace c4

View File

@@ -107,7 +107,7 @@ baz0:
}
INSTANTIATE_GROUP(NESTED_MAPX3);
INSTANTIATE_GROUP(NESTED_MAPX3)
} // namespace yml
} // namespace c4

View File

@@ -192,7 +192,7 @@ baz0:
)
}
INSTANTIATE_GROUP(NESTED_MAPX4);
INSTANTIATE_GROUP(NESTED_MAPX4)
} // namespace yml
} // namespace c4

View File

@@ -141,7 +141,7 @@ R"(
}
INSTANTIATE_GROUP(NESTED_SEQX2);
INSTANTIATE_GROUP(NESTED_SEQX2)
} // namespace yml
} // namespace c4

View File

@@ -192,7 +192,7 @@ R"(
)
}
INSTANTIATE_GROUP(NESTED_SEQX3);
INSTANTIATE_GROUP(NESTED_SEQX3)
} // namespace yml
} // namespace c4

View File

@@ -126,7 +126,7 @@ R"(
)
}
INSTANTIATE_GROUP(NESTED_SEQX4);
INSTANTIATE_GROUP(NESTED_SEQX4)
} // namespace yml
} // namespace c4

View File

@@ -111,7 +111,7 @@ L{N("~"), N("~"), N(L{N("foo", "~"), N("bar", "~"), N("baz", "~")})}
)
}
INSTANTIATE_GROUP(NULL_VAL);
INSTANTIATE_GROUP(NULL_VAL)
} // namespace yml
} // namespace c4

View File

@@ -50,7 +50,7 @@ L{N("-2.0"), N("-2.1"), N("0.1"), N(".1"), N("-.2"), N("-2.e+6"), N("-3e-6"), N(
}
INSTANTIATE_GROUP(NUMBER);
INSTANTIATE_GROUP(NUMBER)
} // namespace yml
} // namespace c4

View File

@@ -142,7 +142,7 @@ R"(
)
}
INSTANTIATE_GROUP(PLAIN_SCALAR);
INSTANTIATE_GROUP(PLAIN_SCALAR)
} // namespace yml
} // namespace c4

View File

@@ -1,5 +1,16 @@
#include "./test_group.hpp"
#if defined(_MSC_VER)
# pragma warning(push)
//# pragma warning(disable: 4127/*conditional expression is constant*/)
//# pragma warning(disable: 4389/*'==': signed/unsigned mismatch*/)
#elif defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
#endif
namespace c4 {
namespace yml {
@@ -66,7 +77,15 @@ L{__(a), __(b), __(c), __(.foo), __(.), __(-a), __(+b), __(/b), __(:c), __($g)}
)
}
INSTANTIATE_GROUP(SCALAR_NAMES);
INSTANTIATE_GROUP(SCALAR_NAMES)
} // namespace yml
} // namespace c4
#if defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif

View File

@@ -72,7 +72,7 @@ R"(
)
}
INSTANTIATE_GROUP(SEQ_OF_MAP);
INSTANTIATE_GROUP(SEQ_OF_MAP)
} // namespace yml
} // namespace c4

View File

@@ -555,7 +555,7 @@ N{"step", L{
)
}
INSTANTIATE_GROUP(SIMPLE_ANCHOR);
INSTANTIATE_GROUP(SIMPLE_ANCHOR)
} // namespace yml
} // namespace c4

View File

@@ -201,7 +201,7 @@ R"(---
);
}
INSTANTIATE_GROUP(SIMPLE_DOC);
INSTANTIATE_GROUP(SIMPLE_DOC)
} // namespace yml
} // namespace c4

View File

@@ -431,7 +431,7 @@ h ,i: val ,000
)
}
INSTANTIATE_GROUP(SIMPLE_MAP);
INSTANTIATE_GROUP(SIMPLE_MAP)
} // namespace yml
} // namespace c4

View File

@@ -460,7 +460,7 @@ L{
)
}
INSTANTIATE_GROUP(SIMPLE_SEQ);
INSTANTIATE_GROUP(SIMPLE_SEQ)
} // namespace yml
} // namespace c4

View File

@@ -32,7 +32,7 @@ N(STREAM, L{N(DOCMAP, TL("!!set", L{N("aa", "~"), N("bb", "~"), N("cc", "~")}))}
)
}
INSTANTIATE_GROUP(SIMPLE_SET);
INSTANTIATE_GROUP(SIMPLE_SET)
} // namespace yml
} // namespace c4

View File

@@ -17,18 +17,18 @@ using ip = int const*;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
template<size_t N>
template<int N>
void test_stack_small_vs_large()
{
istack<N> s;
for(size_t i = 0; i < N; ++i)
for(int i = 0; i < N; ++i)
{
s.push((int)i);
EXPECT_EQ(s.size(), i+1);
s.push(i);
EXPECT_EQ(s.size(), (size_t)i+1);
}
EXPECT_EQ(s.size(), N);
EXPECT_EQ(s.size(), (size_t)N);
EXPECT_EQ(s.m_stack, s.m_buf);
for(size_t i = 0; i < N; ++i)
for(int i = 0; i < N; ++i)
{
EXPECT_EQ(s.top(N-1-i), i);
}
@@ -37,7 +37,7 @@ void test_stack_small_vs_large()
EXPECT_EQ(s.top(), N);
EXPECT_EQ(s.pop(), N);
EXPECT_NE(s.m_stack, s.m_buf);
for(size_t i = 0; i < N; ++i)
for(int i = 0; i < N; ++i)
{
EXPECT_EQ(s.top(N-1-i), i);
}
@@ -121,11 +121,11 @@ void test_move_ctor()
EXPECT_EQ(dst.size(), sz);
EXPECT_EQ(dst.m_stack, dst.m_buf);
EXPECT_NE(dst.m_stack, b);
EXPECT_EQ(src.size(), 0);
EXPECT_EQ(src.size(), size_t(0));
EXPECT_EQ((ip)src.begin(), src.m_buf);
EXPECT_NE((ip)dst.begin(), b);
}
EXPECT_EQ(src.size(), 0);
EXPECT_EQ(src.size(), size_t(0));
EXPECT_EQ(src.capacity(), N);
EXPECT_EQ(src.m_stack, src.m_buf);
@@ -152,7 +152,7 @@ void test_move_ctor()
EXPECT_NE(dst.m_stack, dst.m_buf);
EXPECT_EQ(dst.m_stack, b);
EXPECT_EQ(src.capacity(), N);
EXPECT_EQ(src.size(), 0);
EXPECT_EQ(src.size(), size_t(0));
EXPECT_EQ((ip)src.begin(), src.m_buf);
EXPECT_EQ((ip)dst.begin(), b);
}
@@ -244,7 +244,7 @@ void test_move_assign()
EXPECT_EQ(srcs.m_stack, srcs.m_buf);
EXPECT_NE(srcl.m_stack, srcl.m_buf);
ip bs = srcs.begin(), bl = srcl.begin();
ip bs = srcs.begin()/*, bl = srcl.begin()*/;
size_t szs = srcs.size(), szl = srcl.size();
for(int i = 0; i < 10; ++i)
@@ -257,7 +257,7 @@ void test_move_assign()
dst = std::move(srcs);
EXPECT_TRUE(srcs.empty());
EXPECT_FALSE(dst.empty());
EXPECT_EQ(srcs.size(), 0);
EXPECT_EQ(srcs.size(), size_t(0));
EXPECT_EQ(srcs.capacity(), N);
EXPECT_EQ(dst.size(), szs);
EXPECT_EQ(dst.m_stack, dst.m_buf);
@@ -279,7 +279,7 @@ void test_move_assign()
dst = std::move(srcl);
EXPECT_TRUE(srcl.empty());
EXPECT_FALSE(dst.empty());
EXPECT_EQ(srcl.size(), 0);
EXPECT_EQ(srcl.size(), size_t(0));
EXPECT_EQ(srcl.capacity(), N);
EXPECT_EQ(dst.size(), szl);
EXPECT_NE(dst.m_stack, dst.m_buf);
@@ -315,7 +315,7 @@ TEST(stack, move_assign)
namespace c4 {
namespace yml {
struct Case;
Case const* get_case(csubstr name)
Case const* get_case(csubstr /*name*/)
{
return nullptr;
}

View File

@@ -82,8 +82,9 @@ struct ProcLevel
bool was_parsed = false;
bool was_emitted = false;
void init(c4::csubstr filename, c4::csubstr src_, bool immutable_, bool reuse_, bool is_yaml_events_)
void init(c4::csubstr filename_, c4::csubstr src_, bool immutable_, bool reuse_, bool /*is_yaml_events_*/)
{
filename = filename_;
src.assign(src_.begin(), src_.end());
immutable = immutable_;
reuse = reuse_;
@@ -105,14 +106,19 @@ struct ProcLevel
}
}
#ifdef RYML_DBG
template<class T>
void log(const char* context, T const& v)
{
const char sep[] = "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
#ifdef RYML_DBG
constexpr const char sep[] = "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n";
c4::log("{}:\n{}{}{}", context, sep, v, sep);
#endif
}
#else
template<class T>
void log(const char* /*context*/, T const& /*v*/)
{
}
#endif
void parse()
{
@@ -167,7 +173,7 @@ struct ProcLevel
was_emitted = true;
}
void compare_trees(ProcLevel const& prev)
void compare_trees(ProcLevel const& /*prev*/)
{
if(!was_parsed) parse();
// do it
@@ -407,7 +413,7 @@ struct SuiteCase
// events
C4_CHECK(begin_events != npos);
size_t first_after_events = find_first_after(begin_events, all);
//size_t first_after_events = find_first_after(begin_events, all);
begin_events = 1 + contents.find('\n', begin_events); // skip this line
c4::csubstr src_events = contents.sub(begin_events).trimr(ws);
C4_ASSERT( ! src_events.first_of_any("--- in-yaml", "--- in-json", "--- out-yaml", "---test-event"));
@@ -525,8 +531,8 @@ int main(int argc, char* argv[])
{
c4::log("\n{}: this case is deliberately not implemented in rapidyaml: {}\n",
allowed_to_fail.test_code, allowed_to_fail.reason);
return 0;
}
return 0;
}
if( ! g_suite_case.load(path.str))
{

View File

@@ -93,7 +93,7 @@ R"(some_seq: !its_type [
)
}
INSTANTIATE_GROUP(TAG_PROPERTY);
INSTANTIATE_GROUP(TAG_PROPERTY)
} // namespace yml
} // namespace c4

View File

@@ -24,12 +24,12 @@ void test_compare(Tree const& a, Tree const& b)
{
EXPECT_EQ(a.size(), b.size());
EXPECT_EQ(_num_leaves(a, a.root_id()), _num_leaves(b, b.root_id()));
test_compare(a, a.root_id(), 0, b, b.root_id(), 0, 0);
test_compare(a, a.root_id(), b, b.root_id(), 0);
}
void test_compare(Tree const& a, size_t node_a, size_t pos_a,
Tree const& b, size_t node_b, size_t pos_b,
void test_compare(Tree const& a, size_t node_a,
Tree const& b, size_t node_b,
size_t level)
{
ASSERT_NE(node_a, NONE);
@@ -38,37 +38,37 @@ void test_compare(Tree const& a, size_t node_a, size_t pos_a,
ASSERT_LT(node_b, b.capacity());
EXPECT_EQ(a.type(node_a), b.type(node_b));
EXPECT_EQ(a.has_key(node_a), b.has_key(node_b));
if(a.has_key(node_a) && b.has_key(node_b))
{
EXPECT_EQ(a.key(node_a), b.key(node_b));
}
EXPECT_EQ(a.has_val(node_a), b.has_val(node_b));
if(a.has_val(node_a) && b.has_val(node_b))
{
EXPECT_EQ(a.val(node_a), b.val(node_b));
}
EXPECT_EQ(a.has_key_tag(node_a), b.has_key_tag(node_b));
if(a.has_key_tag(node_a) && b.has_key_tag(node_b))
{
EXPECT_EQ(a.key_tag(node_a), b.key_tag(node_b));
}
EXPECT_EQ(a.has_val_tag(node_a), b.has_val_tag(node_b));
if(a.has_val_tag(node_a) && b.has_val_tag(node_b))
{
EXPECT_EQ(a.val_tag(node_a), b.val_tag(node_b));
}
EXPECT_EQ(a.has_key_anchor(node_a), b.has_key_anchor(node_b));
if(a.has_key_anchor(node_a) && b.has_key_anchor(node_b))
{
EXPECT_EQ(a.key_anchor(node_a), b.key_anchor(node_b));
}
EXPECT_EQ(a.has_val_anchor(node_a), b.has_val_anchor(node_b));
if(a.has_val_anchor(node_a) && b.has_val_anchor(node_b))
{
@@ -78,13 +78,11 @@ void test_compare(Tree const& a, size_t node_a, size_t pos_a,
// check that the children are in the same order
EXPECT_EQ(a.num_children(node_a), b.num_children(node_b));
for(size_t ia = a.first_child(node_a),
ib = b.first_child(node_b),
pa = 0,
pb = 0;
ib = b.first_child(node_b);
ia != NONE && ib != NONE;
ia = a.next_sibling(ia), ib = b.next_sibling(ib), ++pa, ++pb)
ia = a.next_sibling(ia), ib = b.next_sibling(ib))
{
test_compare(a, ia, pa, b, ib, pb, level+1);
test_compare(a, ia, b, ib, level+1);
}
}

View File

@@ -34,8 +34,8 @@ Case const* get_case(csubstr name);
CaseData* get_data(csubstr name);
void test_compare(Tree const& a, Tree const& b);
void test_compare(Tree const& a, size_t node_a, size_t pos_a,
Tree const& b, size_t node_b, size_t pos_b,
void test_compare(Tree const& a, size_t node_a,
Tree const& b, size_t node_b,
size_t level=0);
void test_arena_not_shared(Tree const& a, Tree const& b);

View File

@@ -3,16 +3,29 @@
#include <c4/fs/fs.hpp>
#include <fstream>
// this is needed to include yaml-cpp (!)
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4127/*conditional expression is constant*/)
# pragma warning(disable: 4389/*'==': signed/unsigned mismatch*/)
#elif defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wshadow"
# pragma clang diagnostic ignored "-Wfloat-equal"
# pragma clang diagnostic ignored "-Wunused-parameter"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wshadow"
# pragma GCC diagnostic ignored "-Wfloat-equal"
# pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
#include <yaml-cpp/yaml.h>
#if defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif
namespace c4 {
@@ -120,8 +133,8 @@ TEST_P(YmlTestCase, emit_yml_stringstream)
ss << d->parsed_tree.rootref();
s = ss.str();
csubstr sv = emitrs(d->parsed_tree, &v);
EXPECT_EQ(sv, s);
csubstr sv2 = emitrs(d->parsed_tree, &v);
EXPECT_EQ(sv2, s);
}
}
@@ -139,9 +152,9 @@ TEST_P(YmlTestCase, emit_ofstream)
// using ofstream will use \r\n. So delete it.
std::string filtered;
filtered.reserve(r.size());
for(auto c : r)
for(auto c_ : r)
{
if(c != '\r') filtered += c;
if(c_ != '\r') filtered += c_;
}
EXPECT_EQ(s, filtered);
}

View File

@@ -8,20 +8,19 @@
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4068/*unknown pragma*/)
#endif
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
//#pragma GCC diagnostic ignored "-Wpragma-system-header-outside-header"
#ifdef __clang__
#elif defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunknown-pragmas"
//# pragma GCC diagnostic ignored "-Wpragma-system-header-outside-header"
#endif
namespace c4 {
namespace yml {
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@@ -104,14 +103,12 @@ Case const* get_case(csubstr name)\
} // namespace yml
} // namespace c4
#pragma GCC diagnostic pop
#ifdef __clang__
# pragma clang diagnostic pop
#endif
#if defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif
#endif // C4_RYML_TEST_GROUP_HPP_