mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Merge pull request #5396 from Feoramund/fix-3774
Forbid nested declaration of instrumentation procedures
This commit is contained in:
@@ -1334,12 +1334,16 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
|
|||||||
has_instrumentation = false;
|
has_instrumentation = false;
|
||||||
e->flags |= EntityFlag_Require;
|
e->flags |= EntityFlag_Require;
|
||||||
} else if (ac.instrumentation_enter) {
|
} else if (ac.instrumentation_enter) {
|
||||||
|
init_core_source_code_location(ctx->checker);
|
||||||
if (!is_valid_instrumentation_call(e->type)) {
|
if (!is_valid_instrumentation_call(e->type)) {
|
||||||
init_core_source_code_location(ctx->checker);
|
init_core_source_code_location(ctx->checker);
|
||||||
gbString s = type_to_string(e->type);
|
gbString s = type_to_string(e->type);
|
||||||
error(e->token, "@(instrumentation_enter) procedures must have the type '%s', got %s", instrumentation_proc_type_str, s);
|
error(e->token, "@(instrumentation_enter) procedures must have the type '%s', got %s", instrumentation_proc_type_str, s);
|
||||||
gb_string_free(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);
|
MUTEX_GUARD(&ctx->info->instrumentation_mutex);
|
||||||
if (ctx->info->instrumentation_enter_entity != nullptr) {
|
if (ctx->info->instrumentation_enter_entity != nullptr) {
|
||||||
error(e->token, "@(instrumentation_enter) has already been set");
|
error(e->token, "@(instrumentation_enter) has already been set");
|
||||||
@@ -1356,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);
|
error(e->token, "@(instrumentation_exit) procedures must have the type '%s', got %s", instrumentation_proc_type_str, s);
|
||||||
gb_string_free(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);
|
MUTEX_GUARD(&ctx->info->instrumentation_mutex);
|
||||||
if (ctx->info->instrumentation_exit_entity != nullptr) {
|
if (ctx->info->instrumentation_exit_entity != nullptr) {
|
||||||
error(e->token, "@(instrumentation_exit) has already been set");
|
error(e->token, "@(instrumentation_exit) has already been set");
|
||||||
|
|||||||
Reference in New Issue
Block a user