Fix all valgrind leak issues in tests
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: Deukhoofd <deukhoofd@gmail.com>
This commit is contained in:
2019-06-24 13:38:41 +02:00
parent 76b8ba3ebc
commit 021750a135
13 changed files with 295 additions and 63 deletions

View File

@@ -111,6 +111,10 @@ namespace Porygon::Parser {
delete _expression;
}
void NullifyExpression(){
_expression = nullptr;
}
const ParsedStatementKind GetKind() const final {
return ParsedStatementKind::Expression;
}

View File

@@ -525,7 +525,10 @@ namespace Porygon::Parser {
// If the first item is an expression, and is followed by a comma, we're dealing with a simple {1, 2, 3} kind of array
if (firstItem->GetKind() == ParsedStatementKind::Expression &&
(this->Peek()->GetKind() == TokenKind::CommaToken)) {
auto expr = ((ParsedExpressionStatement *) firstItem)->GetExpression();
auto statement = ((ParsedExpressionStatement *) firstItem);
auto expr = statement->GetExpression();
statement->NullifyExpression();
delete statement;
auto expressions = vector<const ParsedExpression *>{expr};
auto n = this->Next(); // consume the comma
bool hasErrors = false;