Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions change_notes/2024-02-12-exclusion-A2-10-4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
`A2-10-4` - `IdentifierNameOfStaticNonMemberObjectReusedInNamespace.ql`:
Comment thread
knewbury01 marked this conversation as resolved.
Outdated
- Fix FP reported in #385. Addresses incorrect detection of partially specialized template variables as conflicting reuses.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class CandidateVariable extends Variable {
CandidateVariable() {
hasDefinition() and
isStatic() and
not this instanceof MemberVariable
not this instanceof MemberVariable and
//exclude partially specialized template variables
not exists(TemplateVariable v | this = v.getAnInstantiation())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import cpp
import codingstandards.cpp.autosar
import cpp
import codingstandards.cpp.autosar

from FunctionDeclarationEntry f1, FunctionDeclarationEntry f2
where
Expand Down
6 changes: 6 additions & 0 deletions cpp/autosar/test/rules/A2-10-4/test1a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ namespace ns3 {
static void f1() {}

void f2() {}

// Variable templates can cause false positives
template <int x> static int number_one = 0; // COMPLIANT

template <> static int number_one<1> = 1; // COMPLIANT
template <> static int number_one<2> = 2; // COMPLIANT
} // namespace ns3