aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorLucas Perlind <perlindluca@gmail.com>2025-04-27 22:47:03 +1000
committerLucas Perlind <perlindluca@gmail.com>2025-04-27 22:47:03 +1000
commit65b4c793f011ab67ad51773273ebc4333c12bff5 (patch)
tree3d53457878120d7f6431aef068590e3be050e743 /src/parser.cpp
parentc7f9d2b1b78b5bad6c677bf649abafcc5c5270c1 (diff)
Add -vet-explicit-allocators
This vet flag will make it so that allocators must be explicitly used in places where context.allocator and context.temp_allocator are a procedure parameter. The goal of this flag is to prevent using the context.allocator in cases where a different allocator was meant to be used. Some code bases default context.allocator to nil/panic allocator to catch this at runtime. This effectively makes it a compile time error instead.
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index a397585e8..ea95dac31 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -33,6 +33,10 @@ gb_internal bool ast_file_vet_deprecated(AstFile *f) {
return (ast_file_vet_flags(f) & VetFlag_Deprecated) != 0;
}
+gb_internal bool ast_file_vet_explicit_allocators(AstFile *f) {
+ return (ast_file_vet_flags(f) & VetFlag_ExplicitAllocators) != 0;
+}
+
gb_internal bool file_allow_newline(AstFile *f) {
bool is_strict = build_context.strict_style || ast_file_vet_style(f);
return !is_strict;
@@ -6325,6 +6329,7 @@ gb_internal u64 parse_vet_tag(Token token_for_pos, String s) {
error_line("\textra\n");
error_line("\tcast\n");
error_line("\ttabs\n");
+ error_line("\texplicit-allocators\n");
return build_context.vet_flags;
}
}