From 9d299143044f88c2c91dbc8c46cea17cf8de98df Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 30 May 2023 20:26:22 +0100 Subject: Don't strip `builtin` attribute form AST --- src/checker.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/checker.cpp') diff --git a/src/checker.cpp b/src/checker.cpp index c22ad1645..fd5f8e1e8 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -3469,6 +3469,8 @@ gb_internal void check_decl_attributes(CheckerContext *c, Array const &at StringSet set = {}; defer (string_set_destroy(&set)); + bool is_runtime = ((c->scope->parent->flags&(ScopeFlag_File|ScopeFlag_Pkg)) != 0 && c->scope->file->pkg->kind == Package_Runtime); + for_array(i, attributes) { Ast *attr = attributes[i]; if (attr->kind != Ast_Attribute) continue; @@ -3504,6 +3506,10 @@ gb_internal void check_decl_attributes(CheckerContext *c, Array const &at continue; } + if (name == "builtin" && is_runtime) { + continue; + } + if (!proc(c, elem, name, value, ac)) { if (!build_context.ignore_unknown_attributes) { error(elem, "Unknown attribute element name '%.*s'", LIT(name)); @@ -3663,9 +3669,9 @@ gb_internal void check_builtin_attributes(CheckerContext *ctx, Entity *e, Array< error(value, "'builtin' cannot have a field value"); } // Remove the builtin tag - attr->Attribute.elems[k] = attr->Attribute.elems[attr->Attribute.elems.count-1]; - attr->Attribute.elems.count -= 1; - k--; + // attr->Attribute.elems[k] = attr->Attribute.elems[attr->Attribute.elems.count-1]; + // attr->Attribute.elems.count -= 1; + // k--; mutex_unlock(&ctx->info->builtin_mutex); } -- cgit v1.2.3