fix external vectors and only complain about undefined externals that are

actually used
This commit is contained in:
Bill Currie 2002-07-16 20:09:14 +00:00
parent ac1392eb74
commit c36b7e36d2
3 changed files with 13 additions and 11 deletions

View File

@ -186,13 +186,12 @@ vector_component (int is_field, def_t *vec, int comp, scope_t *scope,
if (vec->external) {
d = get_def (is_field ? &type_floatfield : &type_float, name, scope,
st_none);
if (!d) {
if (d) {
error (0, "internal error");
abort ();
}
} else {
d = new_def (is_field ? &type_floatfield : &type_float, name, scope);
}
d = new_def (is_field ? &type_floatfield : &type_float, name, scope);
d->used = 1;
d->parent = vec;
d->ofs = vec->ofs + comp;
@ -248,6 +247,8 @@ get_def (type_t *type, const char *name, scope_t *scope,
def->ofs = new_location (type, space);
}
set_storage_bits (def, storage);
// make automatic defs for the vectors elements .origin can be accessed
// as .origin_x, .origin_y, and .origin_z
if (type->type == ev_vector && name) {
@ -266,7 +267,6 @@ get_def (type_t *type, const char *name, scope_t *scope,
vector_component (1, def, 2, scope, storage);
}
}
set_storage_bits (def, storage);
if (storage == st_extern)
def_initialized (def);

View File

@ -533,12 +533,14 @@ linker_finish (void)
free (undef_defs);
undef_defs = (qfo_def_t **) Hash_GetList (extern_defs);
for (def = undef_defs; *def; def++) {
if ((*def)->num_relocs) {
const char *name = strings->strings + (*def)->name;
pr.source_file = (*def)->file;
pr.source_line = (*def)->line;
pr.strings = strings;
error (0, "undefined symbol %s", name);
}
}
free (undef_defs);
if (pr.error_count)
return 0;

View File

@ -365,9 +365,9 @@ finish_compilation (void)
}
for (d = pr.scope->head; d; d = d->def_next) {
if (d->external) {
if (d->external && d->refs) {
errors = true;
error (0, "undefined global %s\n", d->name);
error (0, "undefined global %s", d->name);
}
}
if (errors)