From 9c5640886d95cba73b10a59a43692c9bae4037fb Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Thu, 5 Jun 2025 14:36:55 -0400 Subject: Add `@(no_sanitize_memory)` proc attribute with MSan additions to `base:sanitizer` --- src/check_decl.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/check_decl.cpp') diff --git a/src/check_decl.cpp b/src/check_decl.cpp index d53c3c6b7..c696fc4c1 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -1370,6 +1370,7 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { e->Procedure.has_instrumentation = has_instrumentation; e->Procedure.no_sanitize_address = ac.no_sanitize_address; + e->Procedure.no_sanitize_memory = ac.no_sanitize_memory; e->deprecated_message = ac.deprecated_message; e->warning_message = ac.warning_message; -- cgit v1.2.3 From d343f54d6d35d304ac16f4335f2d5c5d235597d9 Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Mon, 23 Jun 2025 09:03:50 -0400 Subject: Fix spurious failure to compile procedures marked `@instrumentation_enter` The type `Source_Code_Location` may not be available yet, which causes the compiler to not recognize the procedure type correctly. --- src/check_decl.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/check_decl.cpp') diff --git a/src/check_decl.cpp b/src/check_decl.cpp index c696fc4c1..7458f23d5 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -1334,6 +1334,7 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { has_instrumentation = false; e->flags |= EntityFlag_Require; } else if (ac.instrumentation_enter) { + init_core_source_code_location(ctx->checker); if (!is_valid_instrumentation_call(e->type)) { init_core_source_code_location(ctx->checker); gbString s = type_to_string(e->type); -- cgit v1.2.3 From 3608297e0b8186635b8f52d6c95b16cf6c8f4b7a Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Mon, 23 Jun 2025 09:11:16 -0400 Subject: Forbid nested declaration of instrumentation procedures Fixes #3774 --- src/check_decl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/check_decl.cpp') diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 7458f23d5..3d0d95556 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -1341,6 +1341,9 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { error(e->token, "@(instrumentation_enter) procedures must have the type '%s', got %s", instrumentation_proc_type_str, s); gb_string_free(s); } + if ((e->scope->flags & (ScopeFlag_File|ScopeFlag_Pkg)) == 0) { + error(e->token, "@(instrumentation_enter) procedures must be declared at the file scope"); + } MUTEX_GUARD(&ctx->info->instrumentation_mutex); if (ctx->info->instrumentation_enter_entity != nullptr) { error(e->token, "@(instrumentation_enter) has already been set"); @@ -1357,6 +1360,9 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { error(e->token, "@(instrumentation_exit) procedures must have the type '%s', got %s", instrumentation_proc_type_str, s); gb_string_free(s); } + if ((e->scope->flags & (ScopeFlag_File|ScopeFlag_Pkg)) == 0) { + error(e->token, "@(instrumentation_exit) procedures must be declared at the file scope"); + } MUTEX_GUARD(&ctx->info->instrumentation_mutex); if (ctx->info->instrumentation_exit_entity != nullptr) { error(e->token, "@(instrumentation_exit) has already been set"); -- cgit v1.2.3