fix(frontends/lean/parser): memory leak due to g++ bug
g++ implementation of std::initializer_list has bug. http://gcc.gnu.org/ml/gcc-bugs/2013-06/msg00095.html This commit memory leaks triggered by this bug. It also adds minimal tests to expose three different instances of the problem. Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
97d9765992
commit
3ab2d2a441
7 changed files with 18 additions and 3 deletions
|
@ -152,17 +152,20 @@ expr parser_imp::parse_postfix(expr const & left, operator_info const & op, pos_
|
|||
|
||||
/** \brief Parse a user defined infix operator. */
|
||||
expr parser_imp::parse_infix(expr const & left, operator_info const & op, pos_info const & op_pos) {
|
||||
return mk_application(op, op_pos, {left, parse_expr(op.get_precedence()+1)});
|
||||
expr right = parse_expr(op.get_precedence()+1);
|
||||
return mk_application(op, op_pos, {left, right});
|
||||
}
|
||||
|
||||
/** \brief Parse a user defined infix-left operator. */
|
||||
expr parser_imp::parse_infixl(expr const & left, operator_info const & op, pos_info const & op_pos) {
|
||||
return mk_application(op, op_pos, {left, parse_expr(op.get_precedence())});
|
||||
expr right = parse_expr(op.get_precedence());
|
||||
return mk_application(op, op_pos, {left, right});
|
||||
}
|
||||
|
||||
/** \brief Parse a user defined infix-right operator. */
|
||||
expr parser_imp::parse_infixr(expr const & left, operator_info const & op, pos_info const & op_pos) {
|
||||
return mk_application(op, op_pos, {left, parse_expr(op.get_precedence()-1)});
|
||||
expr right = parse_expr(op.get_precedence()-1);
|
||||
return mk_application(op, op_pos, {left, right});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
1
tests/lean/leak1.lean
Normal file
1
tests/lean/leak1.lean
Normal file
|
@ -0,0 +1 @@
|
|||
print 2 * a
|
3
tests/lean/leak1.lean.expected.out
Normal file
3
tests/lean/leak1.lean.expected.out
Normal file
|
@ -0,0 +1,3 @@
|
|||
Set: pp::colors
|
||||
Set: pp::unicode
|
||||
leak1.lean:1:11: error: unknown identifier 'a'
|
1
tests/lean/leak2.lean
Normal file
1
tests/lean/leak2.lean
Normal file
|
@ -0,0 +1 @@
|
|||
print true /\ a
|
3
tests/lean/leak2.lean.expected.out
Normal file
3
tests/lean/leak2.lean.expected.out
Normal file
|
@ -0,0 +1,3 @@
|
|||
Set: pp::colors
|
||||
Set: pp::unicode
|
||||
leak2.lean:1:15: error: unknown identifier 'a'
|
1
tests/lean/leak3.lean
Normal file
1
tests/lean/leak3.lean
Normal file
|
@ -0,0 +1 @@
|
|||
print true = a
|
3
tests/lean/leak3.lean.expected.out
Normal file
3
tests/lean/leak3.lean.expected.out
Normal file
|
@ -0,0 +1,3 @@
|
|||
Set: pp::colors
|
||||
Set: pp::unicode
|
||||
leak3.lean:1:14: error: unknown identifier 'a'
|
Loading…
Reference in a new issue