diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index 1a82029f1..34059ba51 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -3026,12 +3026,33 @@ sizeof_expr (expr_t *expr, struct type_s *type) return expr; } +static void +report_function (expr_t *e) +{ + static function_t *last_func = (function_t *)-1L; + string_t file = pr.source_file; + + if (e) + file = e->file; + + if (current_func != last_func) { + if (current_func) { + fprintf (stderr, "%s: In function `%s':\n", G_GETSTR (file), + current_func->def->name); + } else { + fprintf (stderr, "%s: At top level:\n", G_GETSTR (file)); + } + } + last_func = current_func; +} + static void _warning (expr_t *e, const char *fmt, va_list args) { string_t file = pr.source_file; int line = pr.source_line; + report_function (e); if (options.warnings.promote) { options.warnings.promote = 0; // only want to do this once fprintf (stderr, "%s: warnings treated as errors\n", "qfcc"); @@ -3062,6 +3083,7 @@ notice (expr_t *e, const char *fmt, ...) string_t file = pr.source_file; int line = pr.source_line; + report_function (e); if (e) { file = e->file; line = e->line; @@ -3090,6 +3112,7 @@ error (expr_t *e, const char *fmt, ...) string_t file = pr.source_file; int line = pr.source_line; + report_function (e); va_start (args, fmt); if (e) { file = e->file; diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index 9affccbf3..083e453a7 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -561,6 +561,7 @@ end_function : /*empty*/ { current_scope = current_scope->parent; + current_func = 0; } ;