Fix build warnings for Clang and MSVC (#197)

* remove unnecessary semicolons on function definitions

* add virtual destructor to base class

* fix possible loss of data warning for double to int conversion with explicit cast

* ignore Visual Studio build folder

Co-authored-by: Wim Leflere <wleflere@cochlear.com>
This commit is contained in:
Wim Leflere
2021-05-20 12:40:57 +02:00
committed by GitHub
co-authored by Wim Leflere
parent b14f8a1e3a
commit b4b9d8dc16
4 changed files with 13 additions and 8 deletions
+1
View File
@@ -36,6 +36,7 @@ dist
.coveralls.yml
.vscode
.vs
doc/html
doc/latex
+5 -3
View File
@@ -33,6 +33,8 @@ class SetStatementNode;
class NodeVisitor {
public:
virtual ~NodeVisitor() = default;
virtual void visit(const BlockNode& node) = 0;
virtual void visit(const TextNode& node) = 0;
virtual void visit(const ExpressionNode& node) = 0;
@@ -59,7 +61,7 @@ public:
size_t pos;
AstNode(size_t pos) : pos(pos) { }
virtual ~AstNode() { };
virtual ~AstNode() { }
};
@@ -326,7 +328,7 @@ public:
void accept(NodeVisitor& v) const {
v.visit(*this);
};
}
};
class SetStatementNode : public StatementNode {
@@ -338,7 +340,7 @@ public:
void accept(NodeVisitor& v) const {
v.visit(*this);
};
}
};
} // namespace inja
+1 -1
View File
@@ -304,7 +304,7 @@ class Renderer : public NodeVisitor {
case Op::Power: {
auto args = get_arguments<2>(node);
if (args[0]->is_number_integer() && args[1]->get<int>() >= 0) {
int result = std::pow(args[0]->get<int>(), args[1]->get<int>());
int result = static_cast<int>(std::pow(args[0]->get<int>(), args[1]->get<int>()));
result_ptr = std::make_shared<json>(std::move(result));
json_tmp_stack.push_back(result_ptr);
} else {
+6 -4
View File
@@ -2351,6 +2351,8 @@ class SetStatementNode;
class NodeVisitor {
public:
virtual ~NodeVisitor() = default;
virtual void visit(const BlockNode& node) = 0;
virtual void visit(const TextNode& node) = 0;
virtual void visit(const ExpressionNode& node) = 0;
@@ -2377,7 +2379,7 @@ public:
size_t pos;
AstNode(size_t pos) : pos(pos) { }
virtual ~AstNode() { };
virtual ~AstNode() { }
};
@@ -2644,7 +2646,7 @@ public:
void accept(NodeVisitor& v) const {
v.visit(*this);
};
}
};
class SetStatementNode : public StatementNode {
@@ -2656,7 +2658,7 @@ public:
void accept(NodeVisitor& v) const {
v.visit(*this);
};
}
};
} // namespace inja
@@ -3672,7 +3674,7 @@ class Renderer : public NodeVisitor {
case Op::Power: {
auto args = get_arguments<2>(node);
if (args[0]->is_number_integer() && args[1]->get<int>() >= 0) {
int result = std::pow(args[0]->get<int>(), args[1]->get<int>());
int result = static_cast<int>(std::pow(args[0]->get<int>(), args[1]->get<int>()));
result_ptr = std::make_shared<json>(std::move(result));
json_tmp_stack.push_back(result_ptr);
} else {