Skip to content

Commit

Permalink
cgen: fix type VType = &C.CType (#19452)
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Sep 27, 2023
1 parent 92a534a commit 8f69bd1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
10 changes: 2 additions & 8 deletions vlib/v/gen/c/cgen.v
Expand Up @@ -1518,17 +1518,11 @@ static inline void __${sym.cname}_pushval(${sym.cname} ch, ${push_arg} val) {
pub fn (mut g Gen) write_alias_typesymbol_declaration(sym ast.TypeSymbol) {
parent := g.table.type_symbols[sym.parent_idx]
is_c_parent := parent.name.len > 2 && parent.name[0] == `C` && parent.name[1] == `.`
mut is_typedef := false
mut is_fixed_array_of_non_builtin := false
if parent.info is ast.Struct {
is_typedef = parent.info.is_typedef
}
mut parent_styp := parent.cname
if is_c_parent {
if !is_typedef {
parent_styp = 'struct ' + parent.cname[3..]
} else {
parent_styp = parent.cname[3..]
if sym.info is ast.Alias {
parent_styp = g.typ(sym.info.parent_type)
}
} else {
if sym.info is ast.Alias {
Expand Down
1 change: 1 addition & 0 deletions vlib/v/gen/c/testdata/alias_c_parent_type_decl.c.must_have
@@ -0,0 +1 @@
typedef struct atype* main__BType;
Empty file.
2 changes: 2 additions & 0 deletions vlib/v/gen/c/testdata/alias_c_parent_type_decl.vv
@@ -0,0 +1,2 @@
struct C.atype{}
type BType = &C.atype

0 comments on commit 8f69bd1

Please sign in to comment.