summaryrefslogtreecommitdiff
path: root/ale_linters/c
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2020-08-19 00:21:22 +0100
committerGitHub <noreply@github.com>2020-08-19 00:21:22 +0100
commit92cada99134dd38d441b7a5a55ddbe7d58882c96 (patch)
tree784be8c73bc3d85750e3ed86927e699be8667ce5 /ale_linters/c
parente27d4377b5dec30a6510a8d45685a37681baaaf0 (diff)
parentfc6677d40565f4c84730a7cfb0af186f183be031 (diff)
downloadale-92cada99134dd38d441b7a5a55ddbe7d58882c96.zip
Merge pull request #3056 from ts826848/remove-ale-std-if-already-in-GetCFlags
[WIP] Avoid overriding parsed C/C++ -std=* flag
Diffstat (limited to 'ale_linters/c')
-rw-r--r--ale_linters/c/clang.vim11
-rw-r--r--ale_linters/c/gcc.vim11
2 files changed, 20 insertions, 2 deletions
diff --git a/ale_linters/c/clang.vim b/ale_linters/c/clang.vim
index 681101fc..84c105de 100644
--- a/ale_linters/c/clang.vim
+++ b/ale_linters/c/clang.vim
@@ -6,13 +6,22 @@ call ale#Set('c_clang_options', '-std=c11 -Wall')
function! ale_linters#c#clang#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
+ let l:ale_flags = ale#Var(a:buffer, 'c_clang_options')
+
+ if l:cflags =~# '-std='
+ let l:ale_flags = substitute(
+ \ l:ale_flags,
+ \ '-std=\(c\|gnu\)[0-9]\{2\}',
+ \ '',
+ \ 'g')
+ endif
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
return '%e -S -x c -fsyntax-only'
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
- \ . ale#Pad(ale#Var(a:buffer, 'c_clang_options')) . ' -'
+ \ . ale#Pad(l:ale_flags) . ' -'
endfunction
call ale#linter#Define('c', {
diff --git a/ale_linters/c/gcc.vim b/ale_linters/c/gcc.vim
index 1df1018e..252285a3 100644
--- a/ale_linters/c/gcc.vim
+++ b/ale_linters/c/gcc.vim
@@ -6,6 +6,15 @@ call ale#Set('c_gcc_options', '-std=c11 -Wall')
function! ale_linters#c#gcc#GetCommand(buffer, output) abort
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
+ let l:ale_flags = ale#Var(a:buffer, 'c_gcc_options')
+
+ if l:cflags =~# '-std='
+ let l:ale_flags = substitute(
+ \ l:ale_flags,
+ \ '-std=\(c\|gnu\)[0-9]\{2\}',
+ \ '',
+ \ 'g')
+ endif
" -iquote with the directory the file is in makes #include work for
" headers in the same directory.
@@ -16,7 +25,7 @@ function! ale_linters#c#gcc#GetCommand(buffer, output) abort
\ . ' -o ' . g:ale#util#nul_file
\ . ' -iquote ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h'))
\ . ale#Pad(l:cflags)
- \ . ale#Pad(ale#Var(a:buffer, 'c_gcc_options')) . ' -'
+ \ . ale#Pad(l:ale_flags) . ' -'
endfunction
call ale#linter#Define('c', {