diff --git a/change_notes/2026-05-21-fix-fp-rule-5-13-4.md b/change_notes/2026-05-21-fix-fp-rule-5-13-4.md new file mode 100644 index 000000000..854135aae --- /dev/null +++ b/change_notes/2026-05-21-fix-fp-rule-5-13-4.md @@ -0,0 +1,5 @@ +- `RULE-5-13-4` - `cpp/misra/unsigned-integer-literals-not-appropriately-suffixed`: + - Remove FPs in user-defined literals and template instantiations. +- `M2-13-3` - `cpp/autosar/missing-u-suffix`: + - Remove FPs in user-defined literals and template instantiations. + \ No newline at end of file diff --git a/cpp/common/src/codingstandards/cpp/Cpp14Literal.qll b/cpp/common/src/codingstandards/cpp/Cpp14Literal.qll index 8e0c089f4..1bd815eba 100644 --- a/cpp/common/src/codingstandards/cpp/Cpp14Literal.qll +++ b/cpp/common/src/codingstandards/cpp/Cpp14Literal.qll @@ -5,9 +5,20 @@ */ module Cpp14Literal { private import cpp as StandardLibrary + private import codingstandards.cpp.UserDefinedLiteral /** An numeric literal. */ - abstract class NumericLiteral extends StandardLibrary::Literal { } + abstract class NumericLiteral extends StandardLibrary::Literal { + NumericLiteral() { + // exclude user-defined literals as they define custom suffixes + not exists(StandardLibrary::FunctionCall fc | + this = fc.getArgument(0) and + fc.getTarget() instanceof UserDefinedLiteral + ) and + // exclude literals derived from template instantiations + not this.isFromTemplateInstantiation(_) + } + } /** Convenience for implementing class `UnrecognizedNumericLiteral` */ abstract private class RecognizedNumericLiteral extends StandardLibrary::Literal { }