commit e53eb2c6754d2813a7df8def69c392ae710d05f7 Author: Jiang Date: Wed Aug 6 21:08:33 2014 +0800 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 see: 66_macro_concat_end.c diff --git a/libtcc.c b/libtcc.c index 7caa7c1..70eeaad 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 || (tok == CH_EOF && line_num > 1)) + 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); diff --git a/tests/tests2/66_macro_concat_end.expect b/tests/tests2/66_macro_concat_end.expect index 224e5c9..8dbf5bb 100644 --- a/tests/tests2/66_macro_concat_end.expect +++ b/tests/tests2/66_macro_concat_end.expect @@ -1 +1 @@ -66_macro_concat_end.c:2: error: '##' invalid at end of macro +66_macro_concat_end.c:1: error: '##' invalid at end of macro