From 1c00fa77fa23bca9f0eb6dc41d0360a135b6fd7a Mon Sep 17 00:00:00 2001 From: yhirose Date: Tue, 19 Jan 2021 12:03:06 -0500 Subject: [PATCH] Fixed warnings --- CMakeLists.txt | 2 ++ peglib.h | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d5f99a..78cceec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,8 @@ set(CMAKE_CXX_EXTENSIONS OFF) if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus /utf-8") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") endif() set(THREADS_PREFER_PTHREAD_FLAG ON) diff --git a/peglib.h b/peglib.h index 77b9bbb..dcc1bb1 100644 --- a/peglib.h +++ b/peglib.h @@ -635,7 +635,7 @@ struct ErrorInfo { if (message_pos) { auto line = line_info(s, message_pos); std::string msg; - if (auto unexpected_token = heuristic_error_token(log, s, n, message_pos); + if (auto unexpected_token = heuristic_error_token(s, n, message_pos); !unexpected_token.empty()) { msg = replace_all(message, "%t", unexpected_token); } else { @@ -652,7 +652,7 @@ struct ErrorInfo { msg = "syntax error"; // unexpected token - if (auto unexpected_token = heuristic_error_token(log, s, n, error_pos); + if (auto unexpected_token = heuristic_error_token(s, n, error_pos); !unexpected_token.empty()) { msg += ", unexpected '"; msg += unexpected_token; @@ -690,7 +690,7 @@ struct ErrorInfo { } private: - std::string heuristic_error_token(const Log &log, const char *s, size_t n, + std::string heuristic_error_token(const char *s, size_t n, const char *error_pos) const { auto len = n - std::distance(s, error_pos); if (len) { @@ -2684,8 +2684,8 @@ inline size_t PrecedenceClimbing::parse_expression(const char *s, size_t n, return i; } -inline size_t Recovery::parse_core(const char *s, size_t n, SemanticValues &vs, - Context &c, std::any &dt) const { +inline size_t Recovery::parse_core(const char *s, size_t n, SemanticValues &/*vs*/, + Context &c, std::any &/*dt*/) const { auto save_log = c.log; c.log = nullptr;