mirror of
https://github.com/vlang/v.git
synced 2025-09-17 11:26:17 -04:00
all: support -N, turning *all* notices into errors, to ease the process of finding places that may need attention/correction
This commit is contained in:
parent
37c189c75f
commit
d97474d487
@ -4568,6 +4568,9 @@ fn (mut c Checker) note(message string, pos token.Pos) {
|
|||||||
if c.is_generated {
|
if c.is_generated {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if c.pref.notes_are_errors {
|
||||||
|
c.error(message, pos)
|
||||||
|
}
|
||||||
mut details := ''
|
mut details := ''
|
||||||
if c.error_details.len > 0 {
|
if c.error_details.len > 0 {
|
||||||
details = c.error_details.join('\n')
|
details = c.error_details.join('\n')
|
||||||
|
@ -2061,6 +2061,10 @@ fn (mut p Parser) note_with_pos(s string, pos token.Pos) {
|
|||||||
if p.is_generated {
|
if p.is_generated {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if p.pref.notes_are_errors {
|
||||||
|
p.error_with_pos(s, pos)
|
||||||
|
return
|
||||||
|
}
|
||||||
if p.pref.output_mode == .stdout && !p.pref.check_only {
|
if p.pref.output_mode == .stdout && !p.pref.check_only {
|
||||||
util.show_compiler_message('notice:', pos: pos, file_path: p.file_name, message: s)
|
util.show_compiler_message('notice:', pos: pos, file_path: p.file_name, message: s)
|
||||||
} else {
|
} else {
|
||||||
|
@ -206,6 +206,7 @@ pub mut:
|
|||||||
skip_warnings bool // like C's "-w", forces warnings to be ignored.
|
skip_warnings bool // like C's "-w", forces warnings to be ignored.
|
||||||
warn_impure_v bool // -Wimpure-v, force a warning for JS.fn()/C.fn(), outside of .js.v/.c.v files. TODO: turn to an error by default
|
warn_impure_v bool // -Wimpure-v, force a warning for JS.fn()/C.fn(), outside of .js.v/.c.v files. TODO: turn to an error by default
|
||||||
warns_are_errors bool // -W, like C's "-Werror", treat *every* warning is an error
|
warns_are_errors bool // -W, like C's "-Werror", treat *every* warning is an error
|
||||||
|
notes_are_errors bool // -N, treat *every* notice as an error
|
||||||
fatal_errors bool // unconditionally exit after the first error with exit(1)
|
fatal_errors bool // unconditionally exit after the first error with exit(1)
|
||||||
reuse_tmpc bool // do not use random names for .tmp.c and .tmp.c.rsp files, and do not remove them
|
reuse_tmpc bool // do not use random names for .tmp.c and .tmp.c.rsp files, and do not remove them
|
||||||
no_rsp bool // when true, pass C backend options directly on the CLI (do not use `.rsp` files for them, some older C compilers do not support them)
|
no_rsp bool // when true, pass C backend options directly on the CLI (do not use `.rsp` files for them, some older C compilers do not support them)
|
||||||
@ -665,6 +666,9 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
|
|||||||
'-W' {
|
'-W' {
|
||||||
res.warns_are_errors = true
|
res.warns_are_errors = true
|
||||||
}
|
}
|
||||||
|
'-N' {
|
||||||
|
res.notes_are_errors = true
|
||||||
|
}
|
||||||
'-no-rsp' {
|
'-no-rsp' {
|
||||||
res.no_rsp = true
|
res.no_rsp = true
|
||||||
}
|
}
|
||||||
|
@ -1578,7 +1578,19 @@ fn (mut s Scanner) inc_line_number() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn (mut s Scanner) current_pos() token.Pos {
|
||||||
|
return token.Pos{
|
||||||
|
line_nr: s.line_nr
|
||||||
|
pos: s.pos
|
||||||
|
col: s.current_column() - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn (mut s Scanner) note(msg string) {
|
pub fn (mut s Scanner) note(msg string) {
|
||||||
|
if s.pref.notes_are_errors {
|
||||||
|
s.error_with_pos(msg, s.current_pos())
|
||||||
|
return
|
||||||
|
}
|
||||||
pos := token.Pos{
|
pos := token.Pos{
|
||||||
line_nr: s.line_nr
|
line_nr: s.line_nr
|
||||||
pos: s.pos
|
pos: s.pos
|
||||||
@ -1614,12 +1626,7 @@ fn (mut s Scanner) eat_details() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut s Scanner) warn(msg string) {
|
pub fn (mut s Scanner) warn(msg string) {
|
||||||
pos := token.Pos{
|
s.warn_with_pos(msg, s.current_pos())
|
||||||
line_nr: s.line_nr
|
|
||||||
pos: s.pos
|
|
||||||
col: s.current_column() - 1
|
|
||||||
}
|
|
||||||
s.warn_with_pos(msg, pos)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut s Scanner) warn_with_pos(msg string, pos token.Pos) {
|
pub fn (mut s Scanner) warn_with_pos(msg string, pos token.Pos) {
|
||||||
@ -1651,12 +1658,7 @@ pub fn (mut s Scanner) warn_with_pos(msg string, pos token.Pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut s Scanner) error(msg string) {
|
pub fn (mut s Scanner) error(msg string) {
|
||||||
pos := token.Pos{
|
s.error_with_pos(msg, s.current_pos())
|
||||||
line_nr: s.line_nr
|
|
||||||
pos: s.pos
|
|
||||||
col: s.current_column() - 1
|
|
||||||
}
|
|
||||||
s.error_with_pos(msg, pos)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut s Scanner) error_with_pos(msg string, pos token.Pos) {
|
pub fn (mut s Scanner) error_with_pos(msg string, pos token.Pos) {
|
||||||
@ -1697,10 +1699,7 @@ fn (mut s Scanner) vet_error(msg string, fix vet.FixKind) {
|
|||||||
ve := vet.Error{
|
ve := vet.Error{
|
||||||
message: msg
|
message: msg
|
||||||
file_path: s.file_path
|
file_path: s.file_path
|
||||||
pos: token.Pos{
|
pos: s.current_pos()
|
||||||
line_nr: s.line_nr
|
|
||||||
col: s.current_column() - 1
|
|
||||||
}
|
|
||||||
kind: .error
|
kind: .error
|
||||||
fix: fix
|
fix: fix
|
||||||
typ: .default
|
typ: .default
|
||||||
|
Loading…
x
Reference in New Issue
Block a user