diff options
| author | Harold Brenes <harold@hbrenes.com> | 2025-05-03 01:34:01 -0400 |
|---|---|---|
| committer | Harold Brenes <harold@hbrenes.com> | 2025-05-03 03:09:30 -0400 |
| commit | a00b91577d998b3795afd099504a6c2b9d99460e (patch) | |
| tree | 31e5b23479f0db98d1e657e431e615247683061a /src/check_decl.cpp | |
| parent | 5f0b47c373e34c231879b2700e78ab1bbd6219b5 (diff) | |
Prevent multiple uses of the same Objective-C class name
Diffstat (limited to 'src/check_decl.cpp')
| -rw-r--r-- | src/check_decl.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
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) { |