Improved macro handling in gcc
This commit is contained in:
parent
06264c264f
commit
d9a7d6bc23
2 changed files with 53 additions and 1 deletions
|
@ -10,7 +10,7 @@ let s:pragma_error = '#pragma once in main file'
|
||||||
" <stdin>:8:5: warning: conversion lacks type at end of format [-Wformat=]
|
" <stdin>:8:5: warning: conversion lacks type at end of format [-Wformat=]
|
||||||
" <stdin>:10:27: error: invalid operands to binary - (have ‘int’ and ‘char *’)
|
" <stdin>:10:27: error: invalid operands to binary - (have ‘int’ and ‘char *’)
|
||||||
" -:189:7: note: $/${} is unnecessary on arithmetic variables. [SC2004]
|
" -:189:7: note: $/${} is unnecessary on arithmetic variables. [SC2004]
|
||||||
let s:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+)$'
|
let s:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+)?:?(\d+)?:? ([^:]+): (.+)$'
|
||||||
let s:inline_pattern = '\v inlined from .* at \<stdin\>:(\d+):(\d+):$'
|
let s:inline_pattern = '\v inlined from .* at \<stdin\>:(\d+):(\d+):$'
|
||||||
|
|
||||||
function! s:IsHeaderFile(filename) abort
|
function! s:IsHeaderFile(filename) abort
|
||||||
|
@ -117,6 +117,23 @@ function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort
|
||||||
if !empty(l:output)
|
if !empty(l:output)
|
||||||
if !has_key(l:output[-1], 'detail')
|
if !has_key(l:output[-1], 'detail')
|
||||||
let l:output[-1].detail = l:output[-1].text
|
let l:output[-1].detail = l:output[-1].text
|
||||||
|
|
||||||
|
" handle macro expansion errors/notes
|
||||||
|
if l:match[5] =~? '^in expansion of macro ‘\w*\w’$'
|
||||||
|
" if the macro expansion is in the file we're in, add
|
||||||
|
" the lnum and col keys to the previous error
|
||||||
|
if l:match[1] is# '<stdin>'
|
||||||
|
\ && !has_key(l:output[-1], 'col')
|
||||||
|
let l:output[-1].lnum = str2nr(l:match[2])
|
||||||
|
let l:output[-1].col = str2nr(l:match[3])
|
||||||
|
else
|
||||||
|
" the error is not in the current file, and since
|
||||||
|
" macro expansion errors don't show the full path to
|
||||||
|
" the error from the current file, we have to just
|
||||||
|
" give out a generic error message
|
||||||
|
let l:output[-1].text = 'Error found in macro expansion. See :ALEDetail'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:output[-1].detail = l:output[-1].detail . "\n"
|
let l:output[-1].detail = l:output[-1].detail . "\n"
|
||||||
|
|
|
@ -279,3 +279,38 @@ Execute(The GCC handler should handle errors for inlined header functions):
|
||||||
\ ' __open_too_many_args ();',
|
\ ' __open_too_many_args ();',
|
||||||
\ ' ^~~~~~~~~~~~~~~~~~~~~~~',
|
\ ' ^~~~~~~~~~~~~~~~~~~~~~~',
|
||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
|
Execute(The GCC handler should handle macro expansion errors in current file):
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 1,
|
||||||
|
\ 'col': 19,
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ 'text': 'error message',
|
||||||
|
\ 'detail': "error message\n<stdin>:1:19: note: in expansion of macro 'TEST'",
|
||||||
|
\ },
|
||||||
|
\ ],
|
||||||
|
\ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
|
||||||
|
\ '<command-line>: error: error message',
|
||||||
|
\ '<stdin>:1:19: note: in expansion of macro ‘TEST’',
|
||||||
|
\ ' 1 | std::string str = TEST;',
|
||||||
|
\ ' | ^~~~',
|
||||||
|
\ ])
|
||||||
|
|
||||||
|
Execute(The GCC handler should handle macro expansion errors in other files):
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 0,
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ 'text': 'Error found in macro expansion. See :ALEDetail',
|
||||||
|
\ 'detail': "error message\ninc.h:1:19: note: in expansion of macro 'TEST'",
|
||||||
|
\ },
|
||||||
|
\ ],
|
||||||
|
\ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
|
||||||
|
\ '<command-line>: error: error message',
|
||||||
|
\ 'inc.h:1:19: note: in expansion of macro ‘TEST’',
|
||||||
|
\ ' 1 | std::string str = TEST;',
|
||||||
|
\ ' | ^~~~',
|
||||||
|
\ ])
|
||||||
|
|
Reference in a new issue