aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2019-09-30 18:40:56 -0400
committerTucker Evans <tuckerevans24@gmail.com>2019-09-30 18:40:56 -0400
commit46fa458c879ab784f6e320fdf793dd4294efcd56 (patch)
treea4018e3c235017725ca17ffed1b8f8d611f3036a
parent8e354d0b3d76eac27fe2c533db275e21f983b8dd (diff)
Fix check_exists checks safe scopes not just current
-rw-r--r--pc.y6
-rw-r--r--sem_check.c2
2 files changed, 5 insertions, 3 deletions
diff --git a/pc.y b/pc.y
index 07f753f..da58fb5 100644
--- a/pc.y
+++ b/pc.y
@@ -359,13 +359,15 @@ TD
var
:ID
{
- $$ = mkid(scope_safe_search(cur_scope,$1));
+ node *tmp;
+ tmp = check_exists(cur_scope, $1);
+ $$ = mkid(tmp);
free($1);
}
|ID '[' expr ']'
{
node* tmp;
- tmp = scope_safe_search(cur_scope, $1);
+ tmp = check_exists(cur_scope, $1);
$$ = mktree(ARRAY_ACCESS, mkid(tmp), $3);
$$->attr.nval = $$->l->attr.nval;
diff --git a/sem_check.c b/sem_check.c
index 77803e1..fd85c98 100644
--- a/sem_check.c
+++ b/sem_check.c
@@ -27,7 +27,7 @@ char *n;
node *tmp;
char buf[100];
- if(!(tmp = scope_search(s,n))) {
+ if(!(tmp = scope_safe_search(s,n))) {
snprintf(buf, 100, "Cannot find \"%s\"\n", n);
yyerror(buf);
}