it's not the IR's job to fail when a local of the same name is created twice...

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-08-23 17:22:13 +02:00
parent 39a62f495c
commit f9746a59ae
2 changed files with 10 additions and 5 deletions

5
ast.c
View file

@ -995,8 +995,11 @@ bool ast_block_codegen(ast_block *self, ast_function *func, bool lvalue, ir_valu
/* generate locals */
for (i = 0; i < self->locals_count; ++i)
{
if (!ast_local_codegen(self->locals[i], func->ir_func, false))
if (!ast_local_codegen(self->locals[i], func->ir_func, false)) {
if (opts_debug)
asterror(ast_ctx(self), "failed to generate local `%s`", self->locals[i]->name);
return false;
}
}
for (i = 0; i < self->exprs_count; ++i)

10
ir.c
View file

@ -138,7 +138,7 @@ static bool irwarning(lex_ctx ctx, int warntype, const char *fmt, ...)
va_list ap;
int lvl = LVL_WARNING;
if (!OPTS_WARN(warntype))
if (warntype && !OPTS_WARN(warntype))
return false;
if (opts_werror)
@ -426,10 +426,12 @@ ir_value* ir_function_get_local(ir_function *self, const char *name)
ir_value* ir_function_create_local(ir_function *self, const char *name, int vtype, bool param)
{
ir_value *ve = ir_function_get_local(self, name);
if (ve) {
ir_value *ve;
/*
if (ir_function_get_local(self, name))
return NULL;
}
*/
if (param &&
self->locals_count &&