1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix regression with unalised naming conflict with C interop (#18752)

This commit is contained in:
Felipe Pena 2023-07-03 17:12:20 -03:00 committed by GitHub
parent c1550b3efa
commit 3f5995ace8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 1 deletions

View File

@ -22,7 +22,12 @@ fn (mut g Gen) struct_init(node ast.StructInit) {
g.empty_line = false g.empty_line = false
g.write(s) g.write(s)
} }
styp := g.typ(g.table.unaliased_type(node.typ)).replace('*', '') unalised_typ := g.table.unaliased_type(node.typ)
styp := if g.table.sym(unalised_typ).language == .v {
g.typ(unalised_typ).replace('*', '')
} else {
g.typ(node.typ)
}
mut shared_styp := '' // only needed for shared x := St{... mut shared_styp := '' // only needed for shared x := St{...
if styp in c.skip_struct_init { if styp in c.skip_struct_init {
// needed for c++ compilers // needed for c++ compilers

View File

@ -0,0 +1,10 @@
module sub
import sub.foo.c
[typedef]
struct C.sub_foo {
a int
}
pub type Foo = C.sub_foo

View File

@ -0,0 +1,5 @@
typedef struct sub_foo sub_foo;
struct sub_foo {
int a;
};

View File

@ -0,0 +1,7 @@
module c
pub const used_import = 1
#flag -I @VMODROOT
#include "foo.h"

View File

View File

@ -0,0 +1,7 @@
import sub
fn test_vmain() {
sub_foo := &sub.Foo{}
dump(sub_foo)
}