From a00b91577d998b3795afd099504a6c2b9d99460e Mon Sep 17 00:00:00 2001 From: Harold Brenes Date: Sat, 3 May 2025 01:34:01 -0400 Subject: Prevent multiple uses of the same Objective-C class name --- src/check_decl.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/check_decl.cpp') diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 18dc5e6b0..c9f6bd85e 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -524,7 +524,16 @@ gb_internal void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, if (decl != nullptr) { AttributeContext ac = {}; check_decl_attributes(ctx, decl->attributes, type_decl_attribute, &ac); + if (e->kind == Entity_TypeName && ac.objc_class != "") { + + mutex_lock(&ctx->info->objc_class_name_mutex); + bool class_exists = string_set_update(&ctx->info->obcj_class_name_set, ac.objc_class); + mutex_unlock(&ctx->info->objc_class_name_mutex); + if (class_exists) { + error(e->token, "@(objc_class) '%s' has already been used elsewhere", ac.objc_class); + } + e->TypeName.objc_class_name = ac.objc_class; if (ac.objc_is_implementation) { -- cgit v1.2.3