From bcf60562e056265d0197bd3765a4d5256e2ca7ec Mon Sep 17 00:00:00 2001 From: jiang <30155751@qq.com> Date: Fri, 23 May 2014 15:46:08 +0800 Subject: [PATCH] The number of rows to display warning is wrong For example: #define TOK_ASM_weak TOK_WEAK1 #define TOK_ASM_weak TOK_WEAK Output: C8.c:3: warning: TOK_ASM_weak redefined --- libtcc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libtcc.c b/libtcc.c index dc01831d..721eaed8 100644 --- a/libtcc.c +++ b/libtcc.c @@ -576,12 +576,15 @@ static void error1(TCCState *s1, int is_warning, const char *fmt, va_list ap) for (f = file; f && f->filename[0] == ':'; f = f->prev) ; if (f) { + int line_num = f->line_num; for(pf = s1->include_stack; pf < s1->include_stack_ptr; pf++) strcat_printf(buf, sizeof(buf), "In file included from %s:%d:\n", (*pf)->filename, (*pf)->line_num); - if (f->line_num > 0) { + if (line_num > 0) { + if(tok == TOK_LINEFEED) + line_num--; strcat_printf(buf, sizeof(buf), "%s:%d: ", - f->filename, f->line_num); + f->filename, line_num); } else { strcat_printf(buf, sizeof(buf), "%s: ", f->filename); -- 2.11.4.GIT