From 6eee760239cbd813b5e80980df684a3580840c44 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sat, 11 Oct 2025 16:26:07 +0200 Subject: [PATCH] Add `--max-macro-iterations` to set macro iteration limit. --- releasenotes.md | 3 ++- src/build/build.h | 2 ++ src/build/build_options.c | 11 ++++++++++- src/build/builder.c | 3 ++- src/compiler/compiler_internal.h | 1 - src/compiler/sema_stmts.c | 7 ++++++- src/utils/common.h | 2 ++ test/test_suite/compile_time/ct_for_limit.c3 | 6 ++++++ 8 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 test/test_suite/compile_time/ct_for_limit.c3 diff --git a/releasenotes.md b/releasenotes.md index cb2f4bbe1..1847e46eb 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -9,7 +9,8 @@ - `"build-dir"` option now available for `project.json`, added to project. #2323 - Allow `..` ranges to use "a..a-1" in order to express zero length. - Disallow aliasing of `@local` symbols with a higher visibility in the alias. - +- Add `--max-macro-iterations` to set macro iteration limit. + ### Fixes - Bug in `io::write_using_write_byte`. - Bitstruct value cannot be used to index a const array in compile time. #2512 diff --git a/src/build/build.h b/src/build/build.h index 9db58b8d3..1fdd808f9 100644 --- a/src/build/build.h +++ b/src/build/build.h @@ -586,6 +586,7 @@ typedef struct BuildOptions_ SanitizeMode sanitize_mode; uint32_t max_vector_size; uint32_t max_stack_object_size; + uint32_t max_macro_iterations; bool print_keywords; bool print_attributes; bool print_builtins; @@ -728,6 +729,7 @@ typedef struct uint32_t symtab_size; uint32_t max_vector_size; uint32_t max_stack_object_size; + uint32_t max_macro_iterations; uint32_t switchrange_max_size; uint32_t switchjump_max_size; const char **args; diff --git a/src/build/build_options.c b/src/build/build_options.c index 362c9c05e..eee051b94 100644 --- a/src/build/build_options.c +++ b/src/build/build_options.c @@ -182,6 +182,7 @@ static void usage(bool full) print_opt("--win-debug=