Skip to content

Commit 2dc3c18

Browse files
committed
A7-3-1: Do not report special member functions
Special member functions are not inheritable.
1 parent 5283bc8 commit 2dc3c18

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

cpp/autosar/src/rules/A7-3-1/HiddenInheritedNonOverridableMemberFunction.ql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import cpp
1717
import codingstandards.cpp.autosar
18+
import codingstandards.cpp.Class
1819

1920
/**
2021
* Holds if the class has a non-virtual member function with the given name.
@@ -48,7 +49,9 @@ where
4849
) and
4950
// Exclude compiler generated member functions which include things like copy constructor that hide base class
5051
// copy constructors.
51-
not overridingDecl.isCompilerGenerated()
52+
not overridingDecl.isCompilerGenerated() and
53+
// Exclude special member functions, which cannot be inherited.
54+
not overridingDecl instanceof SpecialMemberFunction
5255
select overridingDecl,
5356
"Declaration for member '" + name + "' hides non-overridable inherited member function $@",
5457
hiddenDecl, hiddenDecl.getName()

cpp/autosar/test/rules/A7-3-1/test.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,9 @@ void f2() {
7676
c5.f1(0.0); // calls C5::f1(double)
7777
c5.f2(0); // calls C1::f2(int)
7878
c5.f2(0.0); // calls C5::f2(double)
79-
}
79+
}
80+
81+
class C6 : public C1 {
82+
public:
83+
C6 &operator=(const C6 &); // COMPLIANT
84+
};

0 commit comments

Comments
 (0)