Skip to content

Commit bc2aac3

Browse files
committed
Ignore deleted constructors when considering whether a base class is initialized
1 parent 2a805c0 commit bc2aac3

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A12-1-1`, `RULE-15-1-2` - `InitializeAllVirtualBaseClasses.ql`, `ExplicitConstructorBaseClassInitialization.ql`:
2+
- Remove false positives for deleted member functions.

cpp/common/src/codingstandards/cpp/rules/initializeallvirtualbaseclasses/InitializeAllVirtualBaseClasses.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ query predicate problems(
3838
not c.isCompilerGenerated() and
3939
// Not a defaulted constructor
4040
not c.isDefaulted() and
41+
// Not a deleted constructor
42+
not c.isDeleted() and
4143
declaringType_string = declaringType.getSimpleName() and
4244
baseClass_string = baseClass.getSimpleName() and
4345
message =

cpp/common/test/rules/initializeallvirtualbaseclasses/test.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,13 @@ class Derived6 : public Base2 {
6161

6262
private:
6363
Base2 b;
64+
};
65+
66+
class Base3 {};
67+
68+
class Derived7 final : public Base3 {
69+
public:
70+
Derived7() = delete; // COMPLIANT
71+
Derived7(const Derived7 &) = delete; // COMPLIANT
72+
Derived7(Derived7 &&) = delete; // COMPLIANT
6473
};

0 commit comments

Comments
 (0)