compiler: cflag error - closes #2406 (#2417)

* merge master
* fix blank ident & add cflag error
* undo cflag changes
* add missing brace
* undo change to comptime
* improve error message
* update
pull/2420/head
joe-conigliaro 2019-10-19 08:18:08 +11:00 committed by GitHub
parent 28b24eeef6
commit 22c7438795
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 4 deletions

View File

@ -70,15 +70,16 @@ fn (table &Table) has_cflag(cflag CFlag) bool {
// parse the flags to (table.cflags) []CFlag
// Note: clean up big time (joe-c)
fn (table mut Table) parse_cflag(cflag string, mod string) {
fn (table mut Table) parse_cflag(cflag string, mod string) ?bool {
allowed_flags := [
'framework',
'library',
'I', 'l', 'L',
]
mut flag := cflag.trim_space()
flag_orig := cflag.trim_space()
mut flag := flag_orig
if flag == '' {
return
return true
}
mut fos := ''
mut name := ''
@ -124,6 +125,13 @@ fn (table mut Table) parse_cflag(cflag string, mod string) {
value = flag.trim_space()
index = -1
}
if (name in ['-I', '-l', '-L']) && value == '' {
if name == '-I' || name == '-L' {
return error('bad #flag `$flag_orig`: missing path after `-I`')
} else if name == '-l' {
return error('bad #flag `$flag_orig`: missing library name after `-l`')
}
}
cf := CFlag{
mod: mod,
os: fos,
@ -137,7 +145,7 @@ fn (table mut Table) parse_cflag(cflag string, mod string) {
break
}
}
return
return true
}
//TODO: implement msvc specific c_options_before_target and c_options_after_target ...