Skip to content

Commit f228add

Browse files
committed
A2-10-4: exclude partially specialized template variables
1 parent 5ff2a10 commit f228add

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

cpp/autosar/src/rules/A2-10-4/IdentifierNameOfStaticNonMemberObjectReusedInNamespace.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class CandidateVariable extends Variable {
2020
CandidateVariable() {
2121
hasDefinition() and
2222
isStatic() and
23-
not this instanceof MemberVariable
23+
not this instanceof MemberVariable and
24+
//exclude partially specialized template variables
25+
not exists(TemplateVariable v | this = v.getAnInstantiation())
2426
}
2527
}
2628

cpp/autosar/src/rules/M3-9-1/TypesNotIdenticalInReturnDeclarations.ql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
import cpp
1717
import codingstandards.cpp.autosar
18-
import cpp
19-
import codingstandards.cpp.autosar
2018

2119
from FunctionDeclarationEntry f1, FunctionDeclarationEntry f2
2220
where

cpp/autosar/test/rules/A2-10-4/test1a.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,10 @@ namespace ns3 {
1313
static void f1() {}
1414

1515
void f2() {}
16+
17+
// Variable templates can cause false positives
18+
template <int x> static int number_one = 0; // COMPLIANT
19+
20+
template <> static int number_one<1> = 1; // COMPLIANT
21+
template <> static int number_one<2> = 2; // COMPLIANT
1622
} // namespace ns3

0 commit comments

Comments
 (0)