Skip to content

Commit ce53cca

Browse files
authored
fix(braces): F+ line of just whitespace in a macro (#412)
Fixes #406
1 parent 9f4e9df commit ce53cca

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

cpplint.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4962,7 +4962,8 @@ def CheckBraces(filename, clean_lines, linenum, error):
49624962
"Else clause should be indented at the same level as if. "
49634963
"Ambiguous nested if/else chains require braces.",
49644964
)
4965-
elif next_indent > if_indent:
4965+
# assume blank line with \ at the end (for macros) = de-indent
4966+
elif next_indent > if_indent and not re.match(r"\s*\\", next_line):
49664967
error(
49674968
filename,
49684969
linenum,

cpplint_unittest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4506,6 +4506,15 @@ def testConditionals(self):
45064506
)
45074507
self.TestMultiLineLint(
45084508
"""
4509+
#define MACRO \
4510+
if (func1()) \
4511+
return false; \
4512+
\
4513+
func2();""",
4514+
"",
4515+
)
4516+
self.TestMultiLineLint(
4517+
"""
45094518
if constexpr (foo) {
45104519
goto fail;
45114520
goto fail;

0 commit comments

Comments
 (0)