Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ TBA
===

* Fixed a whitespace/newline false positive for control conditions containing lambdas. (#410)
* Fixed a false positive where C++20 templated lambdas (``[]<T>(...)``) triggered the redundant trailing semicolon warning. (#385)

2.0.2 (2025-04-08)
===========
Expand Down
1 change: 1 addition & 0 deletions cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5186,6 +5186,7 @@ def CheckTrailingSemicolon(filename, clean_lines, linenum, error):
)
)
or (func and not re.search(r"\boperator\s*\[\s*\]", func.group(1)))
or re.search(r"\]\s*<.*>\s*$", line_prefix)
or re.search(r"\b(?:struct|union)\s+alignas\s*$", line_prefix)
or re.search(r"\bdecltype$", line_prefix)
or re.search(r"\brequires.*$", line_prefix)
Expand Down
15 changes: 15 additions & 0 deletions cpplint_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3186,6 +3186,21 @@ def testLambda(self):
# Avoid false positives with operator[]
self.TestLint("table_to_children[&*table].push_back(dependent);", "")

# C++20 templated lambdas: []<T>(...) must not trigger the redundant
# trailing semicolon check. Regression test for #385.
self.TestLint("auto x = []<typename T>(T) {};", "")
self.TestLint("auto x = [&]<typename T, int N>(T (&a)[N]) {};", "")
self.TestMultiLineLint(
"auto x = []<typename T>(T t) {\n return t;\n};\n",
"",
)
# A templated *function* (not a lambda) with a redundant trailing
# semicolon must still be flagged.
self.TestLint(
"template <typename T> void f() {};",
"You don't need a ; after a } [readability/braces] [4]",
)

def testBraceInitializerList(self):
self.TestLint("MyStruct p = {1, 2};", "")
self.TestLint("MyStruct p{1, 2};", "")
Expand Down