From e382265a615e8d038e8dbfa707379a9cb0debd78 Mon Sep 17 00:00:00 2001 From: Evan Haas Date: Mon, 25 Dec 2023 14:34:34 -0800 Subject: [PATCH] Diagnostics: handle macro backtrace limit of 1 --- src/aro/Diagnostics.zig | 2 +- test/cases/macro backtrace limit.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/cases/macro backtrace limit.c diff --git a/src/aro/Diagnostics.zig b/src/aro/Diagnostics.zig index f0c08a36..472c4c3c 100644 --- a/src/aro/Diagnostics.zig +++ b/src/aro/Diagnostics.zig @@ -291,7 +291,7 @@ pub fn addExtra( .kind = .note, .extra = .{ .unsigned = expansion_locs.len - d.macro_backtrace_limit }, }); - i = half - 1; + i = half -| 1; while (i > 0) { i -= 1; d.list.appendAssumeCapacity(.{ diff --git a/test/cases/macro backtrace limit.c b/test/cases/macro backtrace limit.c new file mode 100644 index 00000000..e2d15067 --- /dev/null +++ b/test/cases/macro backtrace limit.c @@ -0,0 +1,8 @@ +//aro-args -fmacro-backtrace-limit=1 +#define FOO(X) X +FOO(2) + +#define EXPECTED_ERRORS "macro backtrace limit.c:3:1: error: expected external declaration" \ + "note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)" \ + "macro backtrace limit.c:3:5: note: expanded from here" \ +