Fixed linter bug where was thinking catch was a C style cast

The linter script has exceptions to exclude incorrect detection of C
style casts. Added the keyword catch to this list. Added a regression
test to verify this.
This commit is contained in:
thk123 2016-12-08 17:49:06 +00:00 committed by Michael Tautschnig
parent ddd871cf63
commit 50eac162ad
3 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1,12 @@
/*******************************************************************\
Module: Lint Examples
Author: Thomas Kiley, thomas@diffblue.com
\*******************************************************************/
static fun()
{
catch(int)
}

View File

@ -0,0 +1,6 @@
CORE
main.cpp
^EXIT=0$
^SIGNAL=0$
--

2
scripts/cpplint.py vendored
View File

@ -5270,7 +5270,7 @@ def CheckCStyleCast(filename, clean_lines, linenum, cast_type, pattern, error):
# Exclude lines with keywords that tend to look like casts
context = line[0:match.start(1) - 1]
if Match(r'.*\b(?:sizeof|alignof|alignas|[_A-Z][_A-Z0-9]*)\s*$', context):
if Match(r'.*\b(?:sizeof|alignof|alignas|catch|[_A-Z][_A-Z0-9]*)\s*$', context):
return False
# Try expanding current context to see if we one level of