Skip to content

Commit 945d67a

Browse files
committed
Add support for template base class with compiler generated copy and move constructors/operators
1 parent ecbb588 commit 945d67a

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

cpp/autosar/test/rules/A12-8-6/CopyAndMoveNotDeclaredProtected.expected

+4
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@
2020
| test.cpp:109:3:109:12 | declaration of BaseClass8 | Move constructor for base class 'BaseClass8' is not declared protected or deleted. |
2121
| test.cpp:110:15:110:23 | declaration of operator= | Copy assignment operator for base class 'BaseClass8' is not declared protected or deleted. |
2222
| test.cpp:111:15:111:23 | declaration of operator= | Move constructor for base class 'BaseClass8' is not declared protected or deleted. |
23+
| test.cpp:124:26:124:26 | declaration of BaseClass9 | Implicit copy constructor for base class 'BaseClass9<int>' is not declared protected or deleted. |
24+
| test.cpp:124:26:124:26 | declaration of BaseClass9 | Implicit move constructor for base class 'BaseClass9<int>' is not declared protected or deleted. |
25+
| test.cpp:124:26:124:26 | declaration of operator= | Implicit copy assignment operator for base class 'BaseClass9<int>' is not declared protected or deleted. |
26+
| test.cpp:124:26:124:26 | declaration of operator= | Implicit move assignment operator for base class 'BaseClass9<int>' is not declared protected or deleted. |

cpp/autosar/test/rules/A12-8-6/test.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,23 @@ class DerivedClass9 // COMPLIANT - not a base class itself
121121
T t;
122122
};
123123

124+
template <class T> class BaseClass9 { // NON_COMPLIANT
125+
126+
public:
127+
BaseClass9() {}
128+
};
129+
130+
template <class T>
131+
class DerivedClass10 // COMPLIANT - not a base class itself
132+
: public BaseClass9<T> {
133+
public:
134+
DerivedClass10() {}
135+
};
136+
124137
void test() {
125138
BaseClass7<int> b;
126139
DerivedClass7<int> d;
127140
DerivedClass9<int> e;
141+
BaseClass9<int> f;
142+
DerivedClass10<int> g;
128143
}

cpp/common/src/codingstandards/cpp/Class.qll

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import cpp
66
import codingstandards.cpp.Expr
77

88
private Class getADerivedClass(Class c) {
9-
not c instanceof ClassTemplateInstantiation and
10-
not c instanceof TemplateClass and
119
result = c.getADerivedClass()
1210
or
1311
exists(ClassTemplateInstantiation instantiation |

0 commit comments

Comments
 (0)