Skip to content

Commit 05361b7

Browse files
committed
cgen: fix pattern generated by const_init_or_block.vv in vlib/v/gen/c/coutput_test.v, when VFLAGS=-no-parallel is used
1 parent 6ee06d8 commit 05361b7

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

vlib/v/gen/c/cgen.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ pub fn gen(files []&ast.File, mut table ast.Table, pref_ &pref.Preferences) GenO
477477
global_g.file = file
478478
global_g.gen_file()
479479
global_g.cleanups[file.mod.name].drain_builder(mut global_g.cleanup, 100)
480+
global_g.global_tmp_count = 0
481+
global_g.tmp_count = 0
480482
}
481483
util.timing_measure('cgen serial processing')
482484

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
_option_bool _t2 = main__t1();
3+
if (_t2.state != 0) {
4+
IError err = _t2.err;
5+
_v_panic(IError_str(err));
6+
VUNREACHABLE();
7+
;
8+
}
9+
10+
_const_main__barz = (((*(bool*)_t2.data)));
11+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// vtest vflags: -no-skip-unused -no-parallel
2+
fn t1() ?bool {
3+
return true
4+
}
5+
6+
type FooBar = bool
7+
8+
const bar = FooBar(t1() or { panic(err) })
9+
const barz = FooBar(t1() or { panic(err) })

0 commit comments

Comments
 (0)