find the rest (I hope!) of the mis-tested scopes

This commit is contained in:
Bill Currie 2002-06-10 19:26:54 +00:00
parent a771beed74
commit 7a13e6b362
4 changed files with 9 additions and 8 deletions

View file

@ -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 ();

View file

@ -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;

View file

@ -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",