mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: dont generate function if its flag is false (#11021)
This commit is contained in:
parent
820669b011
commit
6dcf72fe9b
@ -392,12 +392,13 @@ pub:
|
||||
attrs []Attr
|
||||
ctdefine_idx int = -1 // the index in fn.attrs of `[if xyz]`, when such attribute exists
|
||||
pub mut:
|
||||
params []Param
|
||||
stmts []Stmt
|
||||
defer_stmts []DeferStmt
|
||||
return_type Type
|
||||
return_type_pos token.Position // `string` in `fn (u User) name() string` position
|
||||
has_return bool
|
||||
params []Param
|
||||
stmts []Stmt
|
||||
defer_stmts []DeferStmt
|
||||
return_type Type
|
||||
return_type_pos token.Position // `string` in `fn (u User) name() string` position
|
||||
has_return bool
|
||||
should_be_skipped bool
|
||||
//
|
||||
comments []Comment // comments *after* the header, but *before* `{`; used for InterfaceDecl
|
||||
next_comments []Comment // coments that are one line after the decl; used for InterfaceDecl
|
||||
|
@ -7983,7 +7983,7 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
|
||||
} else {
|
||||
for mut a in node.attrs {
|
||||
if a.kind == .comptime_define {
|
||||
c.evaluate_once_comptime_if_attribute(mut a)
|
||||
node.should_be_skipped = c.evaluate_once_comptime_if_attribute(mut a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ fn (mut g Gen) process_fn_decl(node ast.FnDecl) {
|
||||
if !g.is_used_by_main(node) {
|
||||
return
|
||||
}
|
||||
if node.should_be_skipped {
|
||||
return
|
||||
}
|
||||
if g.is_builtin_mod && g.pref.gc_mode == .boehm_leak && node.name == 'malloc' {
|
||||
g.definitions.write_string('#define _v_malloc GC_MALLOC\n')
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user