aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Testing/Semantic/t1-2.p2
-rw-r--r--Testing/Semantic/t1-2a.p2
-rw-r--r--Testing/Semantic/t5-4.p2
-rw-r--r--Testing/Semantic/test-semantic.p4
-rw-r--r--node.c10
-rw-r--r--pc.y14
-rw-r--r--scope.c2
-rw-r--r--tree.c2
8 files changed, 31 insertions, 7 deletions
diff --git a/Testing/Semantic/t1-2.p b/Testing/Semantic/t1-2.p
index 62f2d94..a81cad2 100644
--- a/Testing/Semantic/t1-2.p
+++ b/Testing/Semantic/t1-2.p
@@ -4,7 +4,7 @@ program main( input, output );
procedure boo(a: integer);
var b: real;
begin
- b := 1.23
+ b := 1.23
end;
begin
boo(b)
diff --git a/Testing/Semantic/t1-2a.p b/Testing/Semantic/t1-2a.p
index 62f2d94..a81cad2 100644
--- a/Testing/Semantic/t1-2a.p
+++ b/Testing/Semantic/t1-2a.p
@@ -4,7 +4,7 @@ program main( input, output );
procedure boo(a: integer);
var b: real;
begin
- b := 1.23
+ b := 1.23
end;
begin
boo(b)
diff --git a/Testing/Semantic/t5-4.p b/Testing/Semantic/t5-4.p
index 840625a..a31211f 100644
--- a/Testing/Semantic/t5-4.p
+++ b/Testing/Semantic/t5-4.p
@@ -1,7 +1,7 @@
(* ERROR: function updating non-local variable *)
program main( input, output );
var a: integer;
-
+
function foo(b: integer): integer;
begin
foo := a;
diff --git a/Testing/Semantic/test-semantic.p b/Testing/Semantic/test-semantic.p
index 2cb9b8a..616b6b9 100644
--- a/Testing/Semantic/test-semantic.p
+++ b/Testing/Semantic/test-semantic.p
@@ -42,14 +42,14 @@ begin
(* FUNCTION call check: recursive and correct arguments *)
y := foo( x + foo( y, 0.001, a ) * 1, 2.3, b );
-
+
(* ARRAY access check: recursive, correct arguments *)
y := c[ x + c[y] * 45 ];
(* FUNCTION call and ARRAY access *)
y := foo( x + c[y + foo(c[1], d[2], a)] * 1, 2.3 + d[c[foo(c[3],b,d[y])]] );
- (* IF-THEN check *)
+ (* IF-THEN check *)
if ( c[x] * 6 < 7 + moo( y ) and a > d[c[x]] ) then
begin
c[moo(foo(8,9.10,11.0)) + c[12]] := moo( c[y - 1] )
diff --git a/node.c b/node.c
index df56c6f..bde1ed6 100644
--- a/node.c
+++ b/node.c
@@ -52,8 +52,13 @@ node *n;
free(n->name);
n->name = NULL;
- if (n->func_info)
+ if (n->func_info) {
+ if(n->func_info->argv)
+ free(n->func_info->argv);
+ n->func_info->argv = NULL;
+
free(n->func_info);
+ }
n->func_info = NULL;
if (n->array_info)
@@ -69,7 +74,8 @@ node *n;
{
node *tmp;
- for(tmp = n; tmp;) {
+ tmp = n;
+ while(tmp) {
n = tmp->next;
free_node(tmp);
tmp = n;
diff --git a/pc.y b/pc.y
index 8363428..7e4ca78 100644
--- a/pc.y
+++ b/pc.y
@@ -101,7 +101,9 @@ program
'.'
{
set_ret_type($9);
+#ifdef DEBUG
print_tree($9);
+#endif
free_tree($9);
free_tree($4);
#ifdef DEBUG
@@ -175,7 +177,9 @@ sub_prog_declaration
compound_statement
{
set_ret_type($4);
+#ifdef DEBUG
print_tree($4);
+#endif
free_tree($4);
#ifdef DEBUG
print_scope(cur_scope);
@@ -351,6 +355,7 @@ var
:ID
{
$$ = mkid(scope_safe_search(cur_scope,$1));
+ free($1);
}
|ID '[' expr ']'
{
@@ -359,6 +364,7 @@ var
$$ = mktree(ARRAY_ACCESS, mkid(tmp), $3);
$$->attr.nval = $$->l->attr.nval;
+ free($1);
}
;
@@ -369,6 +375,7 @@ proc_statement
tmp = check_exists(cur_scope, $1);
$$ = mktree(PCALL, mkid(tmp), NULL);
+ free($1);
}
|ID '(' expr_list ')'
{
@@ -376,6 +383,8 @@ proc_statement
tmp = check_exists(cur_scope, $1);
$$ = mktree(PCALL, mkid(tmp), $3);
+
+ free($1);
}
/*calls checked with proc_statement*/
;
@@ -431,6 +440,7 @@ factor
tmp = check_exists(cur_scope, $1);
$$ = mkid(tmp);
+ free($1);
}
|ID '[' expr ']'
{
@@ -438,6 +448,8 @@ factor
tmp = check_exists(cur_scope, $1);
$$ = mktree(ARRAY_ACCESS, mkid(tmp), $3);
+
+ free($1);
}
|ID '(' expr_list ')'
{
@@ -446,6 +458,8 @@ factor
tmp = check_exists(cur_scope, $1);
$$ = mktree(FCALL, mkid(tmp), $3);
check_call($$);
+
+ free($1);
}
|INUM
{
diff --git a/scope.c b/scope.c
index 0355014..8b70c5b 100644
--- a/scope.c
+++ b/scope.c
@@ -36,6 +36,8 @@ scope *s;
free_list(s->table[i]);
}
+ /*free_list takes care of freeing s->ret_var*/
+
free(s);
s = NULL;
}
diff --git a/tree.c b/tree.c
index d59fd18..2b6bd9d 100644
--- a/tree.c
+++ b/tree.c
@@ -246,4 +246,6 @@ ptree *t;
free_tree(t->l);
free_tree(t->r);
free(t);
+
+ /*t->attr.nval freed in free_scope*/
}