warn global redefinition

This commit is contained in:
Yuichi Nishiwaki 2013-10-24 22:29:40 +09:00
parent 331fdaba4c
commit 7bb27295c0
3 changed files with 8 additions and 0 deletions

View File

@ -84,6 +84,7 @@ struct pic_proc *pic_codegen(pic_state *, pic_value);
void pic_abort(pic_state *, const char *); void pic_abort(pic_state *, const char *);
void pic_raise(pic_state *, pic_value); void pic_raise(pic_state *, pic_value);
void pic_error(pic_state *, const char *); void pic_error(pic_state *, const char *);
void pic_warn(pic_state *, const char *);
void pic_debug(pic_state *, pic_value); void pic_debug(pic_state *, pic_value);

View File

@ -139,6 +139,7 @@ scope_global_define(pic_state *pic, const char *name)
struct xh_entry *e; struct xh_entry *e;
if ((e = xh_get(pic->global_tbl, name))) { if ((e = xh_get(pic->global_tbl, name))) {
pic_warn(pic, "redefining global");
return e->val; return e->val;
} }
e = xh_put(pic->global_tbl, name, pic->glen++); e = xh_put(pic->global_tbl, name, pic->glen++);

View File

@ -20,3 +20,9 @@ pic_abort(pic_state *pic, const char *msg)
puts(msg); puts(msg);
abort(); abort();
} }
void
pic_warn(pic_state *pic, const char *msg)
{
fprintf(stderr, "warn: %s\n", msg);
}