cgen: fix code for C ident when ptr is expected (#22259)

This commit is contained in:
Felipe Pena 2024-09-20 05:24:03 -03:00 committed by GitHub
parent 9a0f4d8461
commit c866e375e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 0 deletions

View file

@ -2719,6 +2719,8 @@ fn (mut g Gen) ref_or_deref_arg(arg ast.CallArg, expected_type ast.Type, lang as
if expected_type.has_flag(.option) { if expected_type.has_flag(.option) {
g.expr_with_opt(arg.expr, arg_typ, expected_type) g.expr_with_opt(arg.expr, arg_typ, expected_type)
return return
} else if arg.expr is ast.Ident && arg.expr.language == .c {
g.write('(voidptr)')
} else { } else {
g.write('(voidptr)&/*qq*/') g.write('(voidptr)&/*qq*/')
} }

View file

@ -0,0 +1 @@
int (*real_open) (charptr , int , int ) = ((main__RealOpen)((dl__sym((voidptr)RTLD_NEXT, _SLIT("open")))));

View file

@ -0,0 +1,13 @@
module main
import dl
#flag -D_GNU_SOURCE
type RealOpen = fn(charptr, int, int) int
@[export: open]
fn open(filename charptr, oflag int, mode int) int {
real_open := RealOpen((dl.sym(C.RTLD_NEXT, "open")))
return real_open(filename, oflag, mode)
}