From d95cef6c1b9f00948c14a1e5d02a0a2edfb9d82d Mon Sep 17 00:00:00 2001 From: hvellyr Date: Wed, 25 May 2016 09:14:55 +0200 Subject: [PATCH] Fix compiler warnings about unused method parameters --- lint/peglint.cc | 2 +- lint/server.cc | 4 +-- peglib.h | 75 +++++++++++++++++++++++++------------------------ test/test.cc | 6 ++-- 4 files changed, 44 insertions(+), 43 deletions(-) diff --git a/lint/peglint.cc b/lint/peglint.cc index f3c25a0..450ea99 100644 --- a/lint/peglint.cc +++ b/lint/peglint.cc @@ -122,7 +122,7 @@ int main(int argc, const char** argv) std::cout << "pos:lev\trule/ope" << std::endl; std::cout << "-------\t--------" << std::endl; size_t prev_pos = 0; - parser.enable_trace([&](auto name, auto s, auto n, auto& sv, auto& c, auto& dt) { + parser.enable_trace([&](auto name, auto s, auto /*n*/, auto& /*sv*/, auto& c, auto& /*dt*/) { auto pos = s - c.s; auto backtrack = (pos < prev_pos ? "*" : ""); string indent; diff --git a/lint/server.cc b/lint/server.cc index 57b4dd6..976d250 100644 --- a/lint/server.cc +++ b/lint/server.cc @@ -290,7 +290,7 @@ int run_server(int port, const vector& syntax, const vector& source) { Server svr; - svr.get("/", [&](const Request& req, Response& res) { + svr.get("/", [&](const Request& /*req*/, Response& res) { indexHTML = replace_all(indexHTML, "{{syntax}}", string(syntax.data(), syntax.size()).c_str()); indexHTML = replace_all(indexHTML, "{{source}}", string(source.data(), source.size()).c_str()); @@ -333,7 +333,7 @@ int run_server(int port, const vector& syntax, const vector& source) res.set_content(json, "application/json"); }); - svr.set_error_handler([](const Request& req, Response& res) { + svr.set_error_handler([](const Request& /*req*/, Response& res) { const char* fmt = "

Error Status: %d

"; char buf[BUFSIZ]; snprintf(buf, sizeof(buf), fmt, res.status); diff --git a/peglib.h b/peglib.h index e308d01..4ed126a 100644 --- a/peglib.h +++ b/peglib.h @@ -330,7 +330,7 @@ public: Action(F fn) : fn_(make_adaptor(fn, fn)) {} template ::value>::type*& = enabler> - Action(F fn) {} + Action(F /*fn*/) {} template ::value && !std::is_same::value>::type*& = enabler> void operator=(F fn) { @@ -343,7 +343,7 @@ public: } template ::value>::type*& = enabler> - void operator=(F fn) {} + void operator=(F /*fn*/) {} operator bool() const { return (bool)fn_; @@ -358,7 +358,7 @@ private: struct TypeAdaptor { TypeAdaptor(std::function fn) : fn_(fn) {} - any operator()(const SemanticValues& sv, any& dt) { + any operator()(const SemanticValues& sv, any& /*dt*/) { return call(fn_, sv); } std::function fn_; @@ -377,32 +377,32 @@ private: typedef std::function Fty; template - Fty make_adaptor(F fn, R (F::*mf)(const SemanticValues& sv) const) { + Fty make_adaptor(F fn, R (F::* /*mf*/)(const SemanticValues& sv) const) { return TypeAdaptor(fn); } template - Fty make_adaptor(F fn, R (F::*mf)(const SemanticValues& sv)) { + Fty make_adaptor(F fn, R (F::* /*mf*/)(const SemanticValues& sv)) { return TypeAdaptor(fn); } template - Fty make_adaptor(F fn, R (*mf)(const SemanticValues& sv)) { + Fty make_adaptor(F fn, R (* /*mf*/)(const SemanticValues& sv)) { return TypeAdaptor(fn); } template - Fty make_adaptor(F fn, R (F::*mf)(const SemanticValues& sv, any& dt) const) { + Fty make_adaptor(F fn, R (F::* /*mf*/)(const SemanticValues& sv, any& dt) const) { return TypeAdaptor_c(fn); } template - Fty make_adaptor(F fn, R (F::*mf)(const SemanticValues& sv, any& dt)) { + Fty make_adaptor(F fn, R (F::* /*mf*/)(const SemanticValues& sv, any& dt)) { return TypeAdaptor_c(fn); } template - Fty make_adaptor(F fn, R(*mf)(const SemanticValues& sv, any& dt)) { + Fty make_adaptor(F fn, R(* /*mf*/)(const SemanticValues& sv, any& dt)) { return TypeAdaptor_c(fn); } @@ -975,7 +975,7 @@ class Ignore : public Ope public: Ignore(const std::shared_ptr& ope) : ope_(ope) {} - size_t parse(const char* s, size_t n, SemanticValues& sv, Context& c, any& dt) const override { + size_t parse(const char* s, size_t n, SemanticValues& /*sv*/, Context& c, any& dt) const override { const auto& rule = *ope_; auto& chldsv = c.push(); auto se = make_scope_exit([&]() { @@ -1091,25 +1091,26 @@ public: */ struct Ope::Visitor { - virtual void visit(Sequence& ope) {} - virtual void visit(PrioritizedChoice& ope) {} - virtual void visit(ZeroOrMore& ope) {} - virtual void visit(OneOrMore& ope) {} - virtual void visit(Option& ope) {} - virtual void visit(AndPredicate& ope) {} - virtual void visit(NotPredicate& ope) {} - virtual void visit(LiteralString& ope) {} - virtual void visit(CharacterClass& ope) {} - virtual void visit(Character& ope) {} - virtual void visit(AnyCharacter& ope) {} - virtual void visit(Capture& ope) {} - virtual void visit(TokenBoundary& ope) {} - virtual void visit(Ignore& ope) {} - virtual void visit(User& ope) {} - virtual void visit(WeakHolder& ope) {} - virtual void visit(Holder& ope) {} - virtual void visit(DefinitionReference& ope) {} - virtual void visit(Whitespace& ope) {} + virtual ~Visitor() {} + virtual void visit(Sequence& /*ope*/) {} + virtual void visit(PrioritizedChoice& /*ope*/) {} + virtual void visit(ZeroOrMore& /*ope*/) {} + virtual void visit(OneOrMore& /*ope*/) {} + virtual void visit(Option& /*ope*/) {} + virtual void visit(AndPredicate& /*ope*/) {} + virtual void visit(NotPredicate& /*ope*/) {} + virtual void visit(LiteralString& /*ope*/) {} + virtual void visit(CharacterClass& /*ope*/) {} + virtual void visit(Character& /*ope*/) {} + virtual void visit(AnyCharacter& /*ope*/) {} + virtual void visit(Capture& /*ope*/) {} + virtual void visit(TokenBoundary& /*ope*/) {} + virtual void visit(Ignore& /*ope*/) {} + virtual void visit(User& /*ope*/) {} + virtual void visit(WeakHolder& /*ope*/) {} + virtual void visit(Holder& /*ope*/) {} + virtual void visit(DefinitionReference& /*ope*/) {} + virtual void visit(Whitespace& /*ope*/) {} }; struct AssignIDToDefinition : public Ope::Visitor @@ -1157,10 +1158,10 @@ struct IsToken : public Ope::Visitor void visit(OneOrMore& ope) override { ope.ope_->accept(*this); } void visit(Option& ope) override { ope.ope_->accept(*this); } void visit(Capture& ope) override { ope.ope_->accept(*this); } - void visit(TokenBoundary& ope) override { has_token_boundary = true; } + void visit(TokenBoundary& /*ope*/) override { has_token_boundary = true; } void visit(Ignore& ope) override { ope.ope_->accept(*this); } void visit(WeakHolder& ope) override { ope.weak_.lock()->accept(*this); } - void visit(DefinitionReference& ope) override { has_rule = true; } + void visit(DefinitionReference& /*ope*/) override { has_rule = true; } bool is_token() const { return has_token_boundary || !has_rule; @@ -1731,13 +1732,13 @@ private: void visit(LiteralString& ope) override { done_ = !ope.lit_.empty(); } - void visit(CharacterClass& ope) override { + void visit(CharacterClass& /*ope*/) override { done_ = true; } - void visit(Character& ope) override { + void visit(Character& /*ope*/) override { done_ = true; } - void visit(AnyCharacter& ope) override { + void visit(AnyCharacter& /*ope*/) override { done_ = true; } void visit(Capture& ope) override { @@ -1749,7 +1750,7 @@ private: void visit(Ignore& ope) override { ope.ope_->accept(*this); } - void visit(User& ope) override { + void visit(User& /*ope*/) override { done_ = true; } void visit(WeakHolder& ope) override { @@ -1982,7 +1983,7 @@ private: g["STAR"] = [](const SemanticValues& sv) { return *sv.c_str(); }; g["PLUS"] = [](const SemanticValues& sv) { return *sv.c_str(); }; - g["DOT"] = [](const SemanticValues& sv) { return dot(); }; + g["DOT"] = [](const SemanticValues& /*sv*/) { return dot(); }; g["BeginCap"] = [](const SemanticValues& sv) { return sv.token(); }; } @@ -2436,7 +2437,7 @@ public: } template - bool parse(const char* s, any& dt, T& val, const char* path = nullptr) const { + bool parse(const char* s, any& dt, T& val, const char* /*path*/ = nullptr) const { auto n = strlen(s); return parse_n(s, n, dt, val); } diff --git a/test/test.cc b/test/test.cc index 310e16c..b18517d 100644 --- a/test/test.cc +++ b/test/test.cc @@ -137,7 +137,7 @@ TEST_CASE("String capture test with embedded match action", "[general]") ROOT <= seq(WS, zom(TAG)); TAG <= seq(chr('['), - cap(TAG_NAME, [&](const char* s, size_t n, size_t id, const std::string& name) { + cap(TAG_NAME, [&](const char* s, size_t n, size_t /*id*/, const std::string& /*name*/) { tags.push_back(string(s, n)); }), chr(']'), @@ -347,7 +347,7 @@ TEST_CASE("Backtracking test", "[general]") ); size_t count = 0; - parser["HELLO"] = [&](const SemanticValues& sv) { + parser["HELLO"] = [&](const SemanticValues& /*sv*/) { count++; }; @@ -779,7 +779,7 @@ TEST_CASE("User rule test", "[user rule]") Rules rules = { { - "NAME", usr([](const char* s, size_t n, SemanticValues& sv, any& dt) -> size_t { + "NAME", usr([](const char* s, size_t n, SemanticValues& /*sv*/, any& /*dt*/) -> size_t { static vector names = { "PEG", "BNF" }; for (const auto& name: names) { if (name.size() <= n && !name.compare(0, name.size(), s, name.size())) {