Skip to content

Commit

Permalink
Fix build warnings for Clang and MSVC (#197)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
WimLeflere and Wim Leflere authored May 20, 2021
1 parent b14f8a1 commit b4b9d8d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dist
.coveralls.yml

.vscode
.vs

doc/html
doc/latex
Expand Down
8 changes: 5 additions & 3 deletions include/inja/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -59,7 +61,7 @@ class AstNode {
size_t pos;

AstNode(size_t pos) : pos(pos) { }
virtual ~AstNode() { };
virtual ~AstNode() { }
};


Expand Down Expand Up @@ -326,7 +328,7 @@ class IncludeStatementNode : public StatementNode {

void accept(NodeVisitor& v) const {
v.visit(*this);
};
}
};

class SetStatementNode : public StatementNode {
Expand All @@ -338,7 +340,7 @@ class SetStatementNode : public StatementNode {

void accept(NodeVisitor& v) const {
v.visit(*this);
};
}
};

} // namespace inja
Expand Down
2 changes: 1 addition & 1 deletion include/inja/renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 6 additions & 4 deletions single_include/inja/inja.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -2377,7 +2379,7 @@ class AstNode {
size_t pos;

AstNode(size_t pos) : pos(pos) { }
virtual ~AstNode() { };
virtual ~AstNode() { }
};


Expand Down Expand Up @@ -2644,7 +2646,7 @@ class IncludeStatementNode : public StatementNode {

void accept(NodeVisitor& v) const {
v.visit(*this);
};
}
};

class SetStatementNode : public StatementNode {
Expand All @@ -2656,7 +2658,7 @@ class SetStatementNode : public StatementNode {

void accept(NodeVisitor& v) const {
v.visit(*this);
};
}
};

} // namespace inja
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b4b9d8d

Please sign in to comment.