mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: fix remaining c warnings and add -Werror to CI (#7021)
This commit is contained in:
parent
5eb7660608
commit
9367dcda10
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
@ -85,7 +85,7 @@ jobs:
|
||||
echo $VFLAGS
|
||||
sudo ln -s $PWD/thirdparty/tcc/tcc.exe /usr/local/bin/tcc ## TODO: remove
|
||||
make -j4
|
||||
./v -cg -o v cmd/v
|
||||
./v -cg -cflags -Werror -o v cmd/v
|
||||
- name: Test v->c
|
||||
run: |
|
||||
thirdparty/tcc/tcc.exe -version
|
||||
@ -145,7 +145,7 @@ jobs:
|
||||
## brew install sdl2 sdl2_ttf sdl2_mixer sdl2_image
|
||||
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
|
||||
- name: Build V
|
||||
run: make -j4 && ./v -o v cmd/v
|
||||
run: make -j4 && ./v -cg -cflags -Werror -o v cmd/v
|
||||
- name: Build V using V
|
||||
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v
|
||||
- name: Test symlink
|
||||
@ -206,7 +206,7 @@ jobs:
|
||||
sudo apt-get install --quiet -y libglfw3 libglfw3-dev libfreetype6-dev libxi-dev libxcursor-dev libasound2-dev
|
||||
## sudo apt-get install --quiet -y libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev
|
||||
- name: Build V
|
||||
run: make -j4 && ./v -cc gcc -o v cmd/v
|
||||
run: make -j4 && ./v -cc gcc -cg -cflags -Werror -o v cmd/v
|
||||
# - name: Test V
|
||||
# run: ./v -silent test-compiler
|
||||
# - name: Test v binaries
|
||||
@ -357,7 +357,7 @@ jobs:
|
||||
gcc --version
|
||||
.\make.bat -gcc
|
||||
- name: Test new v.c
|
||||
run: .\v.exe -o v.c cmd/v && gcc -municode -w v.c
|
||||
run: .\v.exe -o v.c cmd/v && gcc -Werror -municode -w v.c
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
.\v.exe setup-freetype
|
||||
@ -392,6 +392,7 @@ jobs:
|
||||
echo %VFLAGS%
|
||||
echo $VFLAGS
|
||||
.\make.bat -msvc
|
||||
.\v.exe -cflags /WX self
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
.\v.exe setup-freetype
|
||||
@ -433,7 +434,7 @@ jobs:
|
||||
move "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe.old"
|
||||
.\make.bat
|
||||
- name: Test new v.c
|
||||
run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -w -ladvapi32 -bt10 v.c
|
||||
run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -Werror -w -ladvapi32 -bt10 v.c
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
.\v.exe setup-freetype
|
||||
|
@ -48,7 +48,7 @@ fn print_backtrace_skipping_top_frames(xskipframes int) bool {
|
||||
// so there is no need to have their twins in builtin_windows.v
|
||||
fn print_backtrace_skipping_top_frames_mac(skipframes int) bool {
|
||||
$if macos {
|
||||
buffer := [100]byteptr{}
|
||||
buffer := [100]voidptr{}
|
||||
nr_ptrs := C.backtrace(buffer, 100)
|
||||
if nr_ptrs < 2 {
|
||||
eprintln('C.backtrace returned less than 2 frames')
|
||||
@ -61,7 +61,7 @@ fn print_backtrace_skipping_top_frames_mac(skipframes int) bool {
|
||||
|
||||
fn print_backtrace_skipping_top_frames_freebsd(skipframes int) bool {
|
||||
$if freebsd {
|
||||
buffer := [100]byteptr{}
|
||||
buffer := [100]voidptr{}
|
||||
nr_ptrs := C.backtrace(buffer, 100)
|
||||
if nr_ptrs < 2 {
|
||||
eprintln('C.backtrace returned less than 2 frames')
|
||||
|
@ -45,16 +45,16 @@ fn (mut p Process) unix_spawn_process() int {
|
||||
}
|
||||
mut cargv := []charptr{}
|
||||
mut cenvs := []charptr{}
|
||||
cargv << p.filename.str
|
||||
cargv << charptr(p.filename.str)
|
||||
for i in 0 .. p.args.len {
|
||||
cargv << p.args[i].str
|
||||
cargv << charptr(p.args[i].str)
|
||||
}
|
||||
for i in 0 .. p.env.len {
|
||||
cenvs << p.env[i].str
|
||||
cenvs << charptr(p.env[i].str)
|
||||
}
|
||||
cargv << charptr(0)
|
||||
cenvs << charptr(0)
|
||||
C.execve(p.filename.str, cargv.data, cenvs.data)
|
||||
C.execve(charptr(p.filename.str), cargv.data, cenvs.data)
|
||||
// NB: normally execve does not return at all.
|
||||
// If it returns, then something went wrong...
|
||||
eprintln(posix_get_error_msg(C.errno))
|
||||
|
@ -28,10 +28,10 @@ pub struct C.timeval {
|
||||
tv_usec u64
|
||||
}
|
||||
|
||||
fn init_time_base() InternalTimeBase {
|
||||
fn init_time_base() C.mach_timebase_info_data_t {
|
||||
tb := C.mach_timebase_info_data_t{}
|
||||
C.mach_timebase_info(&tb)
|
||||
return InternalTimeBase{numer:tb.numer, denom:tb.denom}
|
||||
return C.mach_timebase_info_data_t{numer:tb.numer, denom:tb.denom}
|
||||
}
|
||||
|
||||
fn sys_mono_now_darwin() u64 {
|
||||
|
@ -316,7 +316,7 @@ fn (mut v Builder) cc() {
|
||||
//
|
||||
if is_cc_clang {
|
||||
if debug_mode {
|
||||
debug_options = '-g3 -O0 -no-pie'
|
||||
debug_options = '-g3 -O0'
|
||||
}
|
||||
optimization_options = '-O3'
|
||||
mut have_flto := true
|
||||
|
@ -1191,7 +1191,7 @@ fn (mut g Gen) for_in(it ast.ForInStmt) {
|
||||
g.writeln(' = (*$atmp)[$i];')
|
||||
}
|
||||
} else if it.kind == .map {
|
||||
// `for key, val in map {`
|
||||
// `for key, val in map {
|
||||
g.writeln('// FOR IN map')
|
||||
idx := g.new_tmp_var()
|
||||
atmp := g.new_tmp_var()
|
||||
@ -1199,7 +1199,7 @@ fn (mut g Gen) for_in(it ast.ForInStmt) {
|
||||
g.write('$atmp_styp $atmp = ')
|
||||
g.expr(it.cond)
|
||||
g.writeln(';')
|
||||
g.writeln('for (int $idx = 0; $idx < ${atmp}.key_values.len; ++$idx) {')
|
||||
g.writeln('for (int $idx = 0; $idx < (int)${atmp}.key_values.len; ++$idx) {')
|
||||
g.writeln('\tif (${atmp}.key_values.keys[$idx].str == 0) {continue;}')
|
||||
if it.key_var != '_' {
|
||||
key_styp := g.typ(it.key_type)
|
||||
|
@ -23,14 +23,14 @@ fn (mut p Parser) hash() ast.HashStmt {
|
||||
val := p.tok.lit
|
||||
kind := val.all_before(' ')
|
||||
p.next()
|
||||
mut main := ''
|
||||
mut main_str := ''
|
||||
mut msg := ''
|
||||
content := val.all_after('$kind ').all_before('//')
|
||||
if content.contains(' #') {
|
||||
main = content.all_before(' #').trim_space()
|
||||
main_str = content.all_before(' #').trim_space()
|
||||
msg = content.all_after(' #').trim_space()
|
||||
} else {
|
||||
main = content.trim_space()
|
||||
main_str = content.trim_space()
|
||||
msg = ''
|
||||
}
|
||||
// p.trace('a.v', 'kind: ${kind:-10s} | pos: ${pos:-45s} | hash: $val')
|
||||
@ -38,7 +38,7 @@ fn (mut p Parser) hash() ast.HashStmt {
|
||||
mod: p.mod
|
||||
val: val
|
||||
kind: kind
|
||||
main: main
|
||||
main: main_str
|
||||
msg: msg
|
||||
pos: pos
|
||||
}
|
||||
|
@ -1367,6 +1367,7 @@ fn (mut p Parser) dot_expr(left ast.Expr) ast.Expr {
|
||||
field_name: field_name
|
||||
pos: name_pos
|
||||
is_mut: is_mut
|
||||
mut_pos: mut_pos
|
||||
}
|
||||
mut node := ast.Expr{}
|
||||
node = sel_expr
|
||||
|
Loading…
Reference in New Issue
Block a user