From 7bb27295c0d44375ca9c00d044a0dc76a3ebdcbb Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 24 Oct 2013 22:29:40 +0900 Subject: [PATCH] warn global redefinition --- include/picrin.h | 1 + src/codegen.c | 1 + src/error.c | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/include/picrin.h b/include/picrin.h index 97b76051..65b12a56 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -84,6 +84,7 @@ struct pic_proc *pic_codegen(pic_state *, pic_value); void pic_abort(pic_state *, const char *); void pic_raise(pic_state *, pic_value); void pic_error(pic_state *, const char *); +void pic_warn(pic_state *, const char *); void pic_debug(pic_state *, pic_value); diff --git a/src/codegen.c b/src/codegen.c index bb411cdf..7d2ed45a 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -139,6 +139,7 @@ scope_global_define(pic_state *pic, const char *name) struct xh_entry *e; if ((e = xh_get(pic->global_tbl, name))) { + pic_warn(pic, "redefining global"); return e->val; } e = xh_put(pic->global_tbl, name, pic->glen++); diff --git a/src/error.c b/src/error.c index b963b3a9..fde4cf95 100644 --- a/src/error.c +++ b/src/error.c @@ -20,3 +20,9 @@ pic_abort(pic_state *pic, const char *msg) puts(msg); abort(); } + +void +pic_warn(pic_state *pic, const char *msg) +{ + fprintf(stderr, "warn: %s\n", msg); +}