Skip to content

Commit 851ceb0

Browse files
committed
fix cpplint#112, identifying of copy constructors should allow combinations of volatile and const
1 parent 80ececc commit 851ceb0

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

cpplint.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3153,7 +3153,8 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum,
31533153
Search(r'\bstd\s*::\s*initializer_list\b', constructor_args[0]))
31543154
copy_constructor = bool(
31553155
onearg_constructor and
3156-
Match(r'(const\s+)?%s(\s*<[^>]*>)?(\s+const)?\s*(?:<\w+>\s*)?&'
3156+
Match(r'((const\s+(volatile\s+)?)?|(volatile\s+(const\s+)?))?'
3157+
r'%s(\s*<[^>]*>)?(\s+const)?\s*(?:<\w+>\s*)?&'
31573158
% re.escape(base_classname), constructor_args[0].strip()))
31583159

31593160
if (not is_marked_explicit and

cpplint_unittest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,24 @@ class Foo {
16691669
Foo(const Foo&);
16701670
};""",
16711671
'')
1672+
self.TestMultiLineLint(
1673+
"""
1674+
class Foo {
1675+
Foo(volatile Foo&);
1676+
};""",
1677+
'')
1678+
self.TestMultiLineLint(
1679+
"""
1680+
class Foo {
1681+
Foo(volatile const Foo&);
1682+
};""",
1683+
'')
1684+
self.TestMultiLineLint(
1685+
"""
1686+
class Foo {
1687+
Foo(const volatile Foo&);
1688+
};""",
1689+
'')
16721690
self.TestMultiLineLint(
16731691
"""
16741692
class Foo {

0 commit comments

Comments
 (0)