Fix troubles with clang

This commit is contained in:
Robin Jadoul 2017-01-31 15:03:08 +01:00
parent 27e95a427c
commit 5f723f1774
2 changed files with 9 additions and 9 deletions

View File

@ -131,15 +131,15 @@ Parser::Value Parser::reduce_opt_arguments(std::deque<Token> subparts) {
}
Parser::Value Parser::reduce_arguments(std::deque<Token> subparts) {
std::unique_ptr<FunctionArguments> args;
FunctionArguments* args;
if (subparts.size() > 1) {
args = std::unique_ptr<FunctionArguments>(dynamic_cast<FunctionArguments*>(subparts[0].value.get()));
args = dynamic_cast<FunctionArguments*>(subparts[0].value.get());
subparts[0].value.release();
} else {
args = std::make_unique<FunctionArguments>();
args = new FunctionArguments();
}
args->push_back(std::move(subparts[subparts.size() - 1].value));
return args;
return std::unique_ptr<AST>(args);
}
Parser::Value Parser::reduce_functiondef(std::deque<Token> subparts) {
@ -164,15 +164,15 @@ Parser::Value Parser::reduce_opt_idents(std::deque<Token> subparts) {
}
Parser::Value Parser::reduce_idents(std::deque<Token> subparts) {
std::unique_ptr<FormalParameters> args;
FormalParameters* args;
if (subparts.size() > 1) {
args = std::unique_ptr<FormalParameters>(dynamic_cast<FormalParameters*>(subparts[0].value.get()));
args = dynamic_cast<FormalParameters*>(subparts[0].value.get());
subparts[0].value.release();
} else {
args = std::make_unique<FormalParameters>();
args = new FormalParameters();
}
args->push_back(std::move(subparts[subparts.size() - 1].value));
return args;
return std::unique_ptr<AST>(args);
}
Parser::Value Parser::reduce_assign(std::deque<Token> subparts) {

View File

@ -38,7 +38,7 @@ TEST(lr1, only) {
grammar.variables = {"s","a","b"};
grammar.terminals = {"A", "B"};
for (const std::pair<std::string, std::vector<std::string>>& p : std::initializer_list<std::pair<std::string, std::vector<std::string>>>({
for (const std::pair<std::string, std::vector<std::string>>& p : std::vector<std::pair<std::string, std::vector<std::string>>>({
{"s", {"B", "a", "A"}},
{"s", {"b", "A"}},
{"s", {"a"}},