diff --git a/tools/qfcc/source/def.c b/tools/qfcc/source/def.c index 1d5de10d6..cc8e5ba36 100644 --- a/tools/qfcc/source/def.c +++ b/tools/qfcc/source/def.c @@ -82,7 +82,7 @@ check_for_name (type_t *type, const char *name, scope_t *scope, int allocate) } if (!name) return 0; - if (!scope && (find_struct (name) || get_enum (name))) { + if (scope->type == sc_static && (find_struct (name) || get_enum (name))) { error (0, "%s redeclared", name); return 0; } @@ -207,7 +207,7 @@ get_def (type_t *type, const char *name, scope_t *scope, int allocate) size = type_size (type->aux_type); scope->space->size += type->num_parms * size; - if (scope->parent) { + if (scope->type != sc_static) { expr_t *e1 = new_expr (); expr_t *e2 = new_expr (); diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index f35a898f8..d252d6e41 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -141,7 +141,7 @@ convert_name (expr_t *e) } d = get_def (NULL, name, current_scope, 0); if (d) { - if (!d->scope) { + if (d->scope->type == sc_static) { new = class_ivar_expr (current_class, name); if (new) goto convert; @@ -569,7 +569,7 @@ print_expr (expr_t *e) case ex_def: if (e->e.def->name) printf ("%s", e->e.def->name); - if (e->e.def->scope) { + if (e->e.def->scope->type != sc_static) { printf ("<%d>", e->e.def->ofs); } else { printf ("[%d]", e->e.def->ofs); @@ -1790,7 +1790,7 @@ address_expr (expr_t *e1, expr_t *e2, type_t *t) case ex_def: type = e1->e.def->type; if (type->type == ev_struct) { - int abs = !e1->e.def->scope; + int abs = e1->e.def->scope->type == sc_static; def_t *def = e1->e.def; e = e1; diff --git a/tools/qfcc/source/method.c b/tools/qfcc/source/method.c index 35fe0b9b6..5073008eb 100644 --- a/tools/qfcc/source/method.c +++ b/tools/qfcc/source/method.c @@ -297,7 +297,7 @@ emit_methods (methodlist_t *_methods, const char *name, int instance) for (i = 0; i < count; i++) new_struct_field (method_list, type_Method.aux_type, 0, vis_public); methods_def = get_def (method_list, va ("_OBJ_%s_METHODS_%s", type, name), - pr.scope, 1); + pr.scope, 1); methods_def->initialized = methods_def->constant = 1; methods = &G_STRUCT (pr_method_list_t, methods_def->ofs); methods->method_next = 0; diff --git a/tools/qfcc/source/qfcc.c b/tools/qfcc/source/qfcc.c index 95ca928ef..dbeddcb95 100644 --- a/tools/qfcc/source/qfcc.c +++ b/tools/qfcc/source/qfcc.c @@ -153,7 +153,7 @@ WriteData (int crc) if (!def->constant && def->type->type != ev_func - && def->type->type != ev_field && def->scope == NULL) + && def->type->type != ev_field && def->scope->type == sc_static) dd->type |= DEF_SAVEGLOBAL; dd->s_name = ReuseString (def->name); dd->ofs = def->ofs; @@ -322,7 +322,8 @@ finish_compilation (void) // check to make sure all functions prototyped have code if (options.warnings.undefined_function) for (d = pr.scope->head; d; d = d->def_next) { - if (d->type->type == ev_func && !d->scope) { // function args ok + if (d->type->type == ev_func && d->scope->type == sc_static) { + // function args ok if (d->used) { if (!d->initialized) { warning (0, "function %s was called but not defined\n",