aboutsummaryrefslogtreecommitdiff
path: root/src/checker.cpp
diff options
context:
space:
mode:
authorflysand7 <thebumboni@gmail.com>2025-01-16 20:07:56 +0300
committerflysand7 <thebumboni@gmail.com>2025-01-16 22:11:30 +0300
commit87b590c99bb30066f47683f2481b44b8d8226a37 (patch)
tree60fcffc047caad69c0e1f00a08113e2bd9cc47c0 /src/checker.cpp
parentaa3f0b86c143802d9e81122698e38361751c7a68 (diff)
Do not warn about stack overflow in range loops 'by reference'
Diffstat (limited to 'src/checker.cpp')
-rw-r--r--src/checker.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/checker.cpp b/src/checker.cpp
index 5d3263789..85077a5c5 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -749,9 +749,15 @@ gb_internal void check_scope_usage_internal(Checker *c, Scope *scope, u64 vet_fl
// TODO(bill): When is a good size warn?
// Is >256 KiB good enough?
if (sz > 1ll<<18) {
- gbString type_str = type_to_string(e->type);
- warning(e->token, "Declaration of '%.*s' may cause a stack overflow due to its type '%s' having a size of %lld bytes", LIT(e->token.string), type_str, cast(long long)sz);
- gb_string_free(type_str);
+ bool is_ref = false;
+ if((e->flags & EntityFlag_ForValue) != 0) {
+ is_ref = type_deref(e->Variable.for_loop_parent_type) != NULL;
+ }
+ if(!is_ref) {
+ gbString type_str = type_to_string(e->type);
+ warning(e->token, "Declaration of '%.*s' may cause a stack overflow due to its type '%s' having a size of %lld bytes", LIT(e->token.string), type_str, cast(long long)sz);
+ gb_string_free(type_str);
+ }
}
}
}