summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/handlers/gcc.vim24
-rw-r--r--test/handler/test_gcc_handler.vader62
2 files changed, 86 insertions, 0 deletions
diff --git a/autoload/ale/handlers/gcc.vim b/autoload/ale/handlers/gcc.vim
index 72d639da..ec16b977 100644
--- a/autoload/ale/handlers/gcc.vim
+++ b/autoload/ale/handlers/gcc.vim
@@ -11,6 +11,7 @@ let s:pragma_error = '#pragma once in main file'
" <stdin>:10:27: error: invalid operands to binary - (have ‘int’ and ‘char *’)
" -:189:7: note: $/${} is unnecessary on arithmetic variables. [SC2004]
let s:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+)$'
+let s:inline_pattern = '\v inlined from .* at \<stdin\>:(\d+):(\d+):$'
function! s:IsHeaderFile(filename) abort
return a:filename =~? '\v\.(h|hpp)$'
@@ -25,6 +26,28 @@ function! s:RemoveUnicodeQuotes(text) abort
return l:text
endfunction
+function! s:ParseInlinedFunctionProblems(buffer, lines) abort
+ let l:output = []
+ let l:pos_match = []
+
+ for l:line in a:lines
+ let l:match = matchlist(l:line, s:pattern)
+
+ if !empty(l:match) && !empty(l:pos_match)
+ call add(l:output, {
+ \ 'lnum': str2nr(l:pos_match[1]),
+ \ 'col': str2nr(l:pos_match[2]),
+ \ 'type': (l:match[4] is# 'error' || l:match[4] is# 'fatal error') ? 'E' : 'W',
+ \ 'text': s:RemoveUnicodeQuotes(l:match[5]),
+ \})
+ endif
+
+ let l:pos_match = matchlist(l:line, s:inline_pattern)
+ endfor
+
+ return l:output
+endfunction
+
" Report problems inside of header files just for gcc and clang
function! s:ParseProblemsInHeaders(buffer, lines) abort
let l:output = []
@@ -129,6 +152,7 @@ endfunction
function! ale#handlers#gcc#HandleGCCFormatWithIncludes(buffer, lines) abort
let l:output = ale#handlers#gcc#HandleGCCFormat(a:buffer, a:lines)
+ call extend(l:output, s:ParseInlinedFunctionProblems(a:buffer, a:lines))
call extend(l:output, s:ParseProblemsInHeaders(a:buffer, a:lines))
return l:output
diff --git a/test/handler/test_gcc_handler.vader b/test/handler/test_gcc_handler.vader
index 3daa9e60..b67483a6 100644
--- a/test/handler/test_gcc_handler.vader
+++ b/test/handler/test_gcc_handler.vader
@@ -217,3 +217,65 @@ Execute(The GCC handler should handle fatal error messages due to missing files)
\ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
\ '<stdin>:3:12: fatal error: foo.h: No such file or directory',
\ ])
+
+Execute(The GCC handler should handle errors for inlined header functions):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 50,
+ \ 'col': 4,
+ \ 'filename': '/usr/include/bits/fcntl2.h',
+ \ 'type': 'E',
+ \ 'text': 'call to ''__open_missing_mode'' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments',
+ \ },
+ \ {
+ \ 'lnum': 44,
+ \ 'col': 5,
+ \ 'filename': '/usr/include/bits/fcntl2.h',
+ \ 'type': 'E',
+ \ 'text': 'call to ''__open_too_many_args'' declared with attribute error: open can be called either with 2 or 3 arguments, not more',
+ \ },
+ \ {
+ \ 'lnum': 7,
+ \ 'col': 10,
+ \ 'type': 'E',
+ \ 'text': 'call to ''__open_missing_mode'' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments',
+ \ },
+ \ {
+ \ 'lnum': 13,
+ \ 'col': 11,
+ \ 'type': 'E',
+ \ 'text': 'call to ''__open_too_many_args'' declared with attribute error: open can be called either with 2 or 3 arguments, not more',
+ \ },
+ \ {
+ \ 'lnum': 1,
+ \ 'text': 'Error found in header. See :ALEDetail',
+ \ 'detail': join([
+ \ 'In file included from /usr/include/fcntl.h:328,',
+ \ ' from <stdin>:1:',
+ \ 'In function ‘open’,',
+ \ ' inlined from ‘main’ at <stdin>:7:10:',
+ \ '/usr/include/bits/fcntl2.h:50:4: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments',
+ \ ' __open_missing_mode ();',
+ \ ' ^~~~~~~~~~~~~~~~~~~~~~',
+ \ 'In function ‘open’,',
+ \ ' inlined from ‘main’ at <stdin>:13:11:',
+ \ '/usr/include/bits/fcntl2.h:44:5: error: call to ‘__open_too_many_args’ declared with attribute error: open can be called either with 2 or 3 arguments, not more',
+ \ ' __open_too_many_args ();',
+ \ ], "\n")
+ \ },
+ \],
+ \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
+ \ 'In file included from /usr/include/fcntl.h:328,',
+ \ ' from <stdin>:1:',
+ \ 'In function ‘open’,',
+ \ ' inlined from ‘main’ at <stdin>:7:10:',
+ \ '/usr/include/bits/fcntl2.h:50:4: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments',
+ \ ' __open_missing_mode ();',
+ \ ' ^~~~~~~~~~~~~~~~~~~~~~',
+ \ 'In function ‘open’,',
+ \ ' inlined from ‘main’ at <stdin>:13:11:',
+ \ '/usr/include/bits/fcntl2.h:44:5: error: call to ‘__open_too_many_args’ declared with attribute error: open can be called either with 2 or 3 arguments, not more',
+ \ ' __open_too_many_args ();',
+ \ ' ^~~~~~~~~~~~~~~~~~~~~~~',
+ \ ])