Add @(entry_point_only) for procedures

This commit is contained in:
gingerBill
2024-01-05 13:38:30 +00:00
parent 70c5153471
commit 2820bbc269
5 changed files with 14 additions and 0 deletions
+1
View File
@@ -908,6 +908,7 @@ gb_internal void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
break;
}
e->Procedure.entry_point_only = ac.entry_point_only;
e->Procedure.is_export = ac.is_export;
e->deprecated_message = ac.deprecated_message;
e->warning_message = ac.warning_message;
+8
View File
@@ -7195,6 +7195,14 @@ gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *c
}
}
add_entity_use(c, operand->expr, initial_entity);
if (initial_entity->Procedure.entry_point_only) {
if (c->curr_proc_decl && c->curr_proc_decl->entity == c->info->entry_point) {
// Okay
} else {
error(operand->expr, "Procedures with the attribute '@(entry_point_only)' can only be called directly from the user-level entry point procedure");
}
}
}
if (operand->mode != Addressing_ProcGroup) {
+3
View File
@@ -3413,6 +3413,9 @@ gb_internal DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
error(elem, "Expected a string value for '%.*s'", LIT(name));
}
return true;
} else if (name == "entry_point_only") {
ac->entry_point_only = true;
return true;
}
return false;
}
+1
View File
@@ -123,6 +123,7 @@ struct AttributeContext {
bool init : 1;
bool fini : 1;
bool set_cold : 1;
bool entry_point_only : 1;
u32 optimization_mode; // ProcedureOptimizationMode
i64 foreign_import_priority_index;
String extra_linker_flags;
+1
View File
@@ -250,6 +250,7 @@ struct Entity {
bool is_export : 1;
bool generated_from_polymorphic : 1;
bool target_feature_disabled : 1;
bool entry_point_only : 1;
String target_feature;
} Procedure;
struct {