diff --git a/change_notes/2024-06-18-fix-fp-616-M9-3-3.md b/change_notes/2024-06-18-fix-fp-616-M9-3-3.md new file mode 100644 index 0000000000..6c13807ed6 --- /dev/null +++ b/change_notes/2024-06-18-fix-fp-616-M9-3-3.md @@ -0,0 +1,2 @@ +- `M9-3-3` - `MemberFunctionStaticIfPossible.ql`: + - Fixes #616. Exclude uninstantiated templates. \ No newline at end of file diff --git a/cpp/autosar/src/rules/M9-3-3/MemberFunctionStaticIfPossible.ql b/cpp/autosar/src/rules/M9-3-3/MemberFunctionStaticIfPossible.ql index 5148e72f79..69634f89c6 100644 --- a/cpp/autosar/src/rules/M9-3-3/MemberFunctionStaticIfPossible.ql +++ b/cpp/autosar/src/rules/M9-3-3/MemberFunctionStaticIfPossible.ql @@ -31,7 +31,8 @@ class NonStaticMemberFunction extends MemberFunction { not this instanceof Constructor and not this instanceof Destructor and not this instanceof Operator and - this.hasDefinition() + this.hasDefinition() and + not this.isFromUninstantiatedTemplate(_) } } diff --git a/cpp/autosar/test/rules/M9-3-3/test.cpp b/cpp/autosar/test/rules/M9-3-3/test.cpp index 5469b41d5c..27e44c9a4b 100644 --- a/cpp/autosar/test/rules/M9-3-3/test.cpp +++ b/cpp/autosar/test/rules/M9-3-3/test.cpp @@ -214,4 +214,11 @@ void fp_reported_in_381() { Z4 z; int i = z.front(); z.fill(i); -} \ No newline at end of file +} + +class ZZ { +public: + template + void fp_616(const T &val) { + } // COMPLIANT - ignore uninstantiated templates for static also +};