aboutsummaryrefslogtreecommitdiff
path: root/semantics.c
diff options
context:
space:
mode:
authorTeddy <[email protected]>2014-04-10 18:27:48 +0800
committerTeddy <[email protected]>2014-04-10 18:27:48 +0800
commitf314c03bdf62b83fe4d2b8d600d15d839a0c32b9 (patch)
tree6543410a26ff84ff78196f1a2bb569a0fb3f223b /semantics.c
parentfe75fc6d0569f6df7ff33c96566873eb3ff10dc2 (diff)
...
Diffstat (limited to 'semantics.c')
-rw-r--r--semantics.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/semantics.c b/semantics.c
index 4c87ebb..6e2075c 100644
--- a/semantics.c
+++ b/semantics.c
@@ -457,11 +457,6 @@ CVar_t semantics_p_decl(CNode *p, CScope_t scope) {
CVar_t var = semantics_declr(p->chd->next,
semantics_type_spec(p->chd, scope),
scope, 0);
- if (!type_is_complete(var->type))
- {
- sprintf(err_buff, "parameter '%s' has incomplete type", var->name);
- ERROR(var->ast);
- }
return var;
}
@@ -1377,7 +1372,7 @@ CVar_t semantics_func(CNode *p, CScope_t scope) {
the global scope, while all the types specified in parameters retain in local scope.
The key point is to make sure semantics_params does not push any var */
CSNode *ntop = scope->top;
- CVar_t p;
+ CVar_t var;
scope->top = ntop->next;
scope->lvl--;
if (cscope_push_var(scope, res))
@@ -1385,8 +1380,15 @@ CVar_t semantics_func(CNode *p, CScope_t scope) {
scope->top = ntop;
scope->lvl++;
- for (p = func->rec.func.params; p; p = p->next)
- cscope_push_var(scope, p);
+ for (var = func->rec.func.params; var; var = var->next)
+ {
+ cscope_push_var(scope, var);
+ if (!type_is_complete(var->type))
+ {
+ sprintf(err_buff, "parameter '%s' has incomplete type", var->name);
+ ERROR(var->ast);
+ }
+ }
}
func->rec.func.local = semantics_comp(p->chd->next->next, scope); /* check comp */
func->rec.func.body = p->chd->next->next;