diff --git a/cpplint.py b/cpplint.py index ad942ba..ae7d446 100755 --- a/cpplint.py +++ b/cpplint.py @@ -5055,6 +5055,7 @@ def CheckTrailingSemicolon(filename, clean_lines, linenum, error): # - Compound literals # - Lambdas # - alignas specifier with anonymous structs + # - references to anonymous struct or union # - decltype # - concepts (requires expression) closing_brace_pos = match.group(1).rfind(")") @@ -5080,6 +5081,12 @@ 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*$", line_prefix) + and re.match( + r"(?:struct|union)\s", opening_parenthesis[0][opening_parenthesis[2] + 1 :] + ) + ) 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) diff --git a/cpplint_unittest.py b/cpplint_unittest.py index 574e5fd..a7571c6 100755 --- a/cpplint_unittest.py +++ b/cpplint_unittest.py @@ -3062,6 +3062,7 @@ def testSemiColonAfterBraces(self): for identifier in ["", " x"]: self.TestLint(keyword + align + typename + " {}" + identifier + ";", "") + self.TestLint("struct mount_attr *attr = &(struct mount_attr){};", "") self.TestLint("class X : public Y {};", "") self.TestLint("class X : public MACRO() {};", "") self.TestLint("class X : public decltype(expr) {};", "")