Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uninited global var generation #152

Merged
merged 16 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/c2v.v
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,13 @@ fn (mut c C2V) var_decl(mut decl_stmt Node) {

fn (mut c C2V) global_var_decl(mut var_decl Node) {
// if the global has children, that means it's initialized, parse the expression
is_inited := var_decl.inner.len > 0
mut is_inited := var_decl.inner.len > 0

if var_decl.inner.len == 1 {
if var_decl.inner[0].kindof(.visibility_attr) {
is_inited = false
}
}

vprintln('\nglobal name=${var_decl.name} typ=${var_decl.ast_type.qualified}')
vprintln(var_decl.str())
Expand Down
3 changes: 3 additions & 0 deletions tests/21.header_uninited_global_var.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define TS_CAPI __attribute__ ((visibility("default")))

TS_CAPI extern const char* tsMeshMaterialTypeBump;
2 changes: 2 additions & 0 deletions tests/21.header_uninited_global_var.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[translated]
module tests
Loading