Fix compiler warning about "old style cast"

This commit is contained in:
hvellyr 2016-05-25 09:16:01 +02:00 committed by gck
parent 5d3d63cf11
commit 5cac962f18
5 changed files with 9 additions and 9 deletions

View File

@ -46,8 +46,8 @@ int main(int argc, const char** argv)
parser["EXPRESSION"] = reduce; parser["EXPRESSION"] = reduce;
parser["TERM"] = reduce; parser["TERM"] = reduce;
parser["TERM_OPERATOR"] = [](const SemanticValues& sv) { return (char)*sv.c_str(); }; parser["TERM_OPERATOR"] = [](const SemanticValues& sv) { return static_cast<char>(*sv.c_str()); };
parser["FACTOR_OPERATOR"] = [](const SemanticValues& sv) { return (char)*sv.c_str(); }; parser["FACTOR_OPERATOR"] = [](const SemanticValues& sv) { return static_cast<char>(*sv.c_str()); };
parser["NUMBER"] = [](const SemanticValues& sv) { return atol(sv.c_str()); }; parser["NUMBER"] = [](const SemanticValues& sv) { return atol(sv.c_str()); };
auto expr = argv[1]; auto expr = argv[1];

View File

@ -49,8 +49,8 @@ int main(int argc, const char** argv)
EXPRESSION <= seq(TERM, zom(seq(TERM_OPERATOR, TERM))), reduce; EXPRESSION <= seq(TERM, zom(seq(TERM_OPERATOR, TERM))), reduce;
TERM <= seq(FACTOR, zom(seq(FACTOR_OPERATOR, FACTOR))), reduce; TERM <= seq(FACTOR, zom(seq(FACTOR_OPERATOR, FACTOR))), reduce;
FACTOR <= cho(NUMBER, seq(chr('('), EXPRESSION, chr(')'))); FACTOR <= cho(NUMBER, seq(chr('('), EXPRESSION, chr(')')));
TERM_OPERATOR <= cls("+-"), [](const SemanticValues& sv) { return (char)*sv.c_str(); }; TERM_OPERATOR <= cls("+-"), [](const SemanticValues& sv) { return static_cast<char>(*sv.c_str()); };
FACTOR_OPERATOR <= cls("*/"), [](const SemanticValues& sv) { return (char)*sv.c_str(); }; FACTOR_OPERATOR <= cls("*/"), [](const SemanticValues& sv) { return static_cast<char>(*sv.c_str()); };
NUMBER <= oom(cls("0-9")), [](const SemanticValues& sv) { return atol(sv.c_str()); }; NUMBER <= oom(cls("0-9")), [](const SemanticValues& sv) { return atol(sv.c_str()); };
auto expr = argv[1]; auto expr = argv[1];

View File

@ -245,7 +245,7 @@ socket_t create_socket(const char* host, int port, Fn fn)
// Make 'reuse address' option available // Make 'reuse address' option available
int yes = 1; int yes = 1;
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&yes, sizeof(yes)); setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char*>(&yes), sizeof(yes));
// bind or connect // bind or connect
if (fn(sock, *rp)) { if (fn(sock, *rp)) {

View File

@ -348,7 +348,7 @@ public:
Action& operator=(const Action& rhs) = default; Action& operator=(const Action& rhs) = default;
operator bool() const { operator bool() const {
return (bool)fn_; return bool(fn_);
} }
any operator()(const SemanticValues& sv, any& dt) const { any operator()(const SemanticValues& sv, any& dt) const {
@ -1518,7 +1518,7 @@ inline void DefinitionReference::accept(Visitor& v) { v.visit(*this); }
inline void Whitespace::accept(Visitor& v) { v.visit(*this); } inline void Whitespace::accept(Visitor& v) { v.visit(*this); }
inline void AssignIDToDefinition::visit(Holder& ope) { inline void AssignIDToDefinition::visit(Holder& ope) {
auto p = (void*)ope.outer_; auto p = static_cast<void*>(ope.outer_);
if (ids.count(p)) { if (ids.count(p)) {
return; return;
} }

View File

@ -551,8 +551,8 @@ TEST_CASE("Calculator test3", "[general]")
// Setup actions // Setup actions
parser["EXPRESSION"] = reduce; parser["EXPRESSION"] = reduce;
parser["TERM"] = reduce; parser["TERM"] = reduce;
parser["TERM_OPERATOR"] = [](const SemanticValues& sv) { return (char)*sv.c_str(); }; parser["TERM_OPERATOR"] = [](const SemanticValues& sv) { return static_cast<char>(*sv.c_str()); };
parser["FACTOR_OPERATOR"] = [](const SemanticValues& sv) { return (char)*sv.c_str(); }; parser["FACTOR_OPERATOR"] = [](const SemanticValues& sv) { return static_cast<char>(*sv.c_str()); };
parser["NUMBER"] = [](const SemanticValues& sv) { return stol(sv.str(), nullptr, 10); }; parser["NUMBER"] = [](const SemanticValues& sv) { return stol(sv.str(), nullptr, 10); };
// Parse // Parse