cgen,markused: remove unused enum declarations too (#25033)

This commit is contained in:
Felipe Pena 2025-08-04 02:44:21 -03:00 committed by GitHub
parent 3b7ada1621
commit b74e60b5a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 6 additions and 2 deletions

View File

@ -729,6 +729,7 @@ fn (t Tree) enum_decl(node ast.EnumDecl) &Node {
obj.add('comments', t.array_node_comment(node.comments))
obj.add_terse('attrs', t.array_node_attr(node.attrs))
obj.add_terse('typ', t.type_node(node.typ))
obj.add_terse('enum_typ', t.type_node(node.enum_typ))
return obj
}

View File

@ -1475,6 +1475,8 @@ pub:
typ Type // the default is `int`; can be changed by `enum Big as u64 { a = 5 }`
typ_pos token.Pos
pos token.Pos
pub mut:
enum_typ Type
}
pub struct AliasTypeDecl {

View File

@ -2161,6 +2161,7 @@ fn (mut c Checker) enum_decl(mut node ast.EnumDecl) {
}
}
}
node.enum_typ = c.table.find_type_idx(node.name)
}
fn (mut c Checker) check_enum_field_integer_literal(expr ast.IntegerLiteral, is_signed bool, is_multi_allowed bool,

View File

@ -4771,7 +4771,7 @@ fn (mut g Gen) enum_decl(node ast.EnumDecl) {
}
return
}
if g.pref.skip_unused && node.typ.idx() !in g.table.used_features.used_syms {
if g.pref.skip_unused && node.enum_typ !in g.table.used_features.used_syms {
return
}
g.enum_typedefs.writeln('')

View File

@ -846,7 +846,7 @@ fn (mut w Walker) expr(node_ ast.Expr) {
w.expr(filtered[0].expr)
}
}
w.mark_by_sym_name(node.enum_name)
w.mark_by_type(node.typ)
}
ast.LockExpr {
w.uses_lock = true