Set GCC flags appropriately for older versions
This commit is contained in:
parent
dfb10f1db2
commit
2c7d14809d
@ -3,16 +3,17 @@
|
||||
|
||||
" Set this option to change the GCC options for warnings for C.
|
||||
if !exists('g:ale_cpp_gcc_options')
|
||||
" added c++14 standard support
|
||||
" POSIX thread and standard c++ thread and atomic library Linker
|
||||
" let g:ale_cpp_gcc_options = '-std=c++1z' for c++17
|
||||
" for previous version and default, you can just use
|
||||
" let g:ale_cpp_gcc_options = '-Wall'
|
||||
" for more see man pages of gcc
|
||||
" $ man g++
|
||||
" make sure g++ in your $PATH
|
||||
" Add flags according to your requirements
|
||||
let g:ale_cpp_gcc_options = '-std=c++14 -Wall'
|
||||
let s:version = ale#handlers#gcc#ParseGCCVersion(systemlist('gcc --version'))
|
||||
|
||||
if !empty(s:version) && ale#semver#GreaterOrEqual(s:version, [4, 9, 0])
|
||||
" Use c++14 support in 4.9 and above.
|
||||
let g:ale_cpp_gcc_options = '-std=c++14 -Wall'
|
||||
else
|
||||
" Use c++1y in older versions.
|
||||
let g:ale_cpp_gcc_options = '-std=c++1y -Wall'
|
||||
endif
|
||||
|
||||
unlet! s:version
|
||||
endif
|
||||
|
||||
function! ale_linters#cpp#gcc#GetCommand(buffer) abort
|
||||
|
@ -26,6 +26,18 @@ function! s:RemoveUnicodeQuotes(text) abort
|
||||
return l:text
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#gcc#ParseGCCVersion(lines) abort
|
||||
for l:line in a:lines
|
||||
let l:match = matchstr(l:line, '\d\.\d\.\d')
|
||||
|
||||
if !empty(l:match)
|
||||
return ale#semver#Parse(l:match)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return []
|
||||
endfunction
|
||||
|
||||
function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort
|
||||
let l:include_pattern = '\v^(In file included | *)from ([^:]*):(\d+)'
|
||||
let l:include_lnum = 0
|
||||
|
@ -66,3 +66,14 @@ Execute(GCC errors from included files should be parsed correctly):
|
||||
\ ' other_bad_type y;',
|
||||
\ ' ^',
|
||||
\ ])
|
||||
|
||||
Execute(GCC versions should be parsed correctly):
|
||||
AssertEqual [4, 9, 1], ale#handlers#gcc#ParseGCCVersion([
|
||||
\ 'g++ (GCC) 4.9.1 20140922 (Red Hat 4.9.1-10)',
|
||||
\])
|
||||
AssertEqual [4, 8, 4], ale#handlers#gcc#ParseGCCVersion([
|
||||
\ 'gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4',
|
||||
\ 'Copyright (C) 2013 Free Software Foundation, Inc.',
|
||||
\ 'This is free software; see the source for copying conditions. There is NO',
|
||||
\ 'warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.',
|
||||
\])
|
||||
|
Loading…
Reference in New Issue
Block a user