Generate a warning when creating a var with no type.

This makes the internal error in new_def() non-functional, but the warning
will catch the bug and there's no harm in leaving the test in new_def().
This commit is contained in:
Bill Currie 2011-02-14 15:44:01 +09:00
parent ee866ae3a6
commit 4c63a0bad6

View file

@ -182,6 +182,11 @@ void
initialize_def (symbol_t *sym, type_t *type, expr_t *init, defspace_t *space,
storage_class_t storage)
{
if (!type) {
warning (0, "type for %s defaults to %s", sym->name,
type_default->name);
type = type_default;
}
if (sym->table == current_symtab) {
if (sym->sy_type != sy_var || sym->type != type) {
error (0, "%s redefined", sym->name);