From 05361b75ca50e30016721c0b260c85ecf43dc783 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sun, 18 May 2025 09:32:26 +0300 Subject: [PATCH] cgen: fix pattern generated by `const_init_or_block.vv` in `vlib/v/gen/c/coutput_test.v`, when VFLAGS=-no-parallel is used --- vlib/v/gen/c/cgen.v | 2 ++ .../const_init_or_block_no_parallel.c.must_have | 11 +++++++++++ .../gen/c/testdata/const_init_or_block_no_parallel.vv | 9 +++++++++ 3 files changed, 22 insertions(+) create mode 100644 vlib/v/gen/c/testdata/const_init_or_block_no_parallel.c.must_have create mode 100644 vlib/v/gen/c/testdata/const_init_or_block_no_parallel.vv diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index c8448c2ca..657723179 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -477,6 +477,8 @@ pub fn gen(files []&ast.File, mut table ast.Table, pref_ &pref.Preferences) GenO global_g.file = file global_g.gen_file() global_g.cleanups[file.mod.name].drain_builder(mut global_g.cleanup, 100) + global_g.global_tmp_count = 0 + global_g.tmp_count = 0 } util.timing_measure('cgen serial processing') diff --git a/vlib/v/gen/c/testdata/const_init_or_block_no_parallel.c.must_have b/vlib/v/gen/c/testdata/const_init_or_block_no_parallel.c.must_have new file mode 100644 index 000000000..cd1f5f927 --- /dev/null +++ b/vlib/v/gen/c/testdata/const_init_or_block_no_parallel.c.must_have @@ -0,0 +1,11 @@ +{ +_option_bool _t2 = main__t1(); +if (_t2.state != 0) { +IError err = _t2.err; +_v_panic(IError_str(err)); +VUNREACHABLE(); +; +} + +_const_main__barz = (((*(bool*)_t2.data))); +} \ No newline at end of file diff --git a/vlib/v/gen/c/testdata/const_init_or_block_no_parallel.vv b/vlib/v/gen/c/testdata/const_init_or_block_no_parallel.vv new file mode 100644 index 000000000..fe26b7674 --- /dev/null +++ b/vlib/v/gen/c/testdata/const_init_or_block_no_parallel.vv @@ -0,0 +1,9 @@ +// vtest vflags: -no-skip-unused -no-parallel +fn t1() ?bool { + return true +} + +type FooBar = bool + +const bar = FooBar(t1() or { panic(err) }) +const barz = FooBar(t1() or { panic(err) }) -- 2.39.5