mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 22:58:46 +00:00
Merge pull request #4703 from flysand7/4685-range-stack-overflow
Do not warn about stack overflow in range loops 'by reference'
This commit is contained in:
+9
-3
@@ -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?
|
// TODO(bill): When is a good size warn?
|
||||||
// Is >256 KiB good enough?
|
// Is >256 KiB good enough?
|
||||||
if (sz > 1ll<<18) {
|
if (sz > 1ll<<18) {
|
||||||
gbString type_str = type_to_string(e->type);
|
bool is_ref = false;
|
||||||
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);
|
if((e->flags & EntityFlag_ForValue) != 0) {
|
||||||
gb_string_free(type_str);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user