aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tree.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/tree.c b/tree.c
index d218eed..d59fd18 100644
--- a/tree.c
+++ b/tree.c
@@ -64,7 +64,8 @@ void update_type_info(list, t)
ptree *list, *t;
{
int type;
- struct ai *info = NULL;
+ struct ai *info, *tmp;
+ info = tmp = NULL;
assert(list && t);
type = t->type;
@@ -82,9 +83,14 @@ ptree *list, *t;
} else while (list->r && list->r->type == ID) {
/*Set type of right child through list*/
list->r->attr.nval->var_type = type;
- if (info)
+ if (info){
list->r->attr.nval->array_info = info;
+ assert(tmp = malloc(sizeof(struct ai)));
+ memcpy(tmp, info, sizeof(struct ai));
+ info = tmp;
+ }
+
if (list->l) {
if (list->l->type == LIST) {
list = list->l;
@@ -95,6 +101,10 @@ ptree *list, *t;
list->l->attr.nval->var_type = type;
if (info){
list->l->attr.nval->array_info = info;
+
+ assert(tmp = malloc(sizeof(struct ai)));
+ memcpy(tmp, info, sizeof(struct ai));
+ info = tmp;
}
}
}