Fix #356 Don't complain about #pragma once in C++ headers

This commit is contained in:
w0rp 2017-04-30 00:30:44 +01:00
parent 2c7d14809d
commit a6cadaabef
2 changed files with 24 additions and 0 deletions

View File

@ -3,6 +3,8 @@ scriptencoding utf-8
" Description: This file defines a handler function which ought to work for
" any program which outputs errors in the format that GCC uses.
let s:pragma_error = '#pragma once in main file'
function! s:AddIncludedErrors(output, include_lnum, include_lines) abort
if a:include_lnum > 0
call add(a:output, {
@ -92,6 +94,11 @@ function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort
let l:include_lines = []
let l:included_filename = ''
if s:IsHeaderFile(bufname(bufnr('')))
\&& l:match[5][:len(s:pragma_error) - 1] ==# s:pragma_error
continue
endif
call add(l:output, {
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,

View File

@ -77,3 +77,20 @@ Execute(GCC versions should be parsed correctly):
\ 'This is free software; see the source for copying conditions. There is NO',
\ 'warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.',
\])
Execute(The GCC handler shouldn't complain about #pragma once for headers):
silent file! test.h
AssertEqual
\ [],
\ ale#handlers#gcc#HandleGCCFormat(347, [
\ '<stdin>:1:1: warning: #pragma once in main file [enabled by default]',
\ ])
silent file! test.hpp
AssertEqual
\ [],
\ ale#handlers#gcc#HandleGCCFormat(347, [
\ '<stdin>:1:1: warning: #pragma once in main file [enabled by default]',
\ ])