From c900dc1053b5b33d58a0f5313c6170074afd7669 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 14 Dec 2021 17:14:45 +0200 Subject: [PATCH] ci: use -Wno-excess-initializers for clang -cstrict, cleanup cgen --- vlib/v/builder/cc.v | 1 + vlib/v/gen/c/cgen.v | 10 +--------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index ec427956e8..89929fe4e3 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -185,6 +185,7 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) { // enable additional warnings: '-Wno-unknown-warning' /* if a C compiler does not understand a certain flag, it should just ignore it */, '-Wno-unknown-warning-option' /* clang equivalent of the above */, + '-Wno-excess-initializers' /* vlib/v/tests/struct_init_with_complex_fields_test.v fails without that on macos clang 13 */, '-Wdate-time', '-Wduplicated-branches', '-Wduplicated-cond', diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 470c8cfef0..6a5e4527ce 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -6816,15 +6816,7 @@ fn (mut g Gen) type_default(typ_ ast.Type) string { } init_str += '.$field_name = $expr_str,' } else { - mut zero_str := g.type_default(field.typ) - if zero_str == '{0}' { - if field_sym.info is ast.Struct { - if field_sym.info.fields.len == 0 - && field_sym.info.embeds.len == 0 { - zero_str = '{0}' - } - } - } + zero_str := g.type_default(field.typ) init_str += '.$field_name = $zero_str,' } has_none_zero = true