diff options
| author | Laytan <laytanlaats@hotmail.com> | 2025-10-08 18:02:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-08 18:02:12 +0200 |
| commit | f564f66c03c8210f718218ef06bdb0be42803792 (patch) | |
| tree | 41bb70fe1192b37d843759a8f1a69dfc5785c925 /src/check_decl.cpp | |
| parent | c1054d4d8e5aadb2384b7159c5294afbf12cb2da (diff) | |
| parent | 9f5bde4a6f2975f5b783a3e0f7d04f5ecd74b63d (diff) | |
Merge pull request #5770 from harold-b/hb.fix-objc-superclass-check
Fix `@objc_superclass` attribute crashing when referenced type was invalid
Diffstat (limited to 'src/check_decl.cpp')
| -rw-r--r-- | src/check_decl.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp index fa4eade0f..e54943d80 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -559,6 +559,11 @@ gb_internal void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, Type *super = ac.objc_superclass; while (super != nullptr) { + if (super->kind != Type_Named) { + error(e->token, "@(objc_superclass) Referenced type must be a named struct"); + break; + } + if (type_set_update(&super_set, super)) { error(e->token, "@(objc_superclass) Superclass hierarchy cycle encountered"); break; @@ -566,11 +571,6 @@ gb_internal void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, check_single_global_entity(ctx->checker, super->Named.type_name, super->Named.type_name->decl_info); - if (super->kind != Type_Named) { - error(e->token, "@(objc_superclass) Referenced type must be a named struct"); - break; - } - Type* named_type = base_named_type(super); GB_ASSERT(named_type->kind == Type_Named); |