Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 10 additions & 8 deletions lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2748,15 +2748,17 @@ namespace { // avoid one-definition-rule violation

void CheckClass::initializerListOrder()
{
if (!mSettings->severity.isEnabled(Severity::style) && !mSettings->isPremiumEnabled("initializerList"))
return;
if (!mSettings->isPremiumEnabled("initializerList")) {
if (!mSettings->severity.isEnabled(Severity::style))
return;

// This check is not inconclusive. However it only determines if the initialization
// order is incorrect. It does not determine if being out of order causes
// a real error. Out of order is not necessarily an error but you can never
// have an error if the list is in order so this enforces defensive programming.
if (!mSettings->certainty.isEnabled(Certainty::inconclusive))
return;
// This check is not inconclusive. However it only determines if the initialization
// order is incorrect. It does not determine if being out of order causes
// a real error. Out of order is not necessarily an error but you can never
// have an error if the list is in order so this enforces defensive programming.
if (!mSettings->certainty.isEnabled(Certainty::inconclusive))
return;
}

logChecker("CheckClass::initializerListOrder"); // style,inconclusive

Expand Down
13 changes: 6 additions & 7 deletions lib/checkersidmapping.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2025 Cppcheck team.
* Copyright (C) 2007-2026 Cppcheck team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -24,7 +24,7 @@ std::vector<checkers::IdMapping> checkers::idMappingAutosar{
{"m0-1-1", "unreachableCode,duplicateBreak"},
{"m0-1-2", "unsignedLessThanZero"},
{"m0-1-3", "unusedVariable,unusedStructMember"},
{"a0-1-1", "unreadVariable,unusedValue,redundantAssignment"},
{"a0-1-1", "unreadVariable,redundantAssignment"},
{"m0-1-9", "redundantAssignment,redundantInitialization"},
{"m0-1-10", "unusedFunction"},
{"m0-2-1", "overlappingWriteUnion,overlappingWriteFunction"},
Expand All @@ -41,7 +41,6 @@ std::vector<checkers::IdMapping> checkers::idMappingAutosar{
{"m5-0-17", "comparePointers"},
{"m5-0-18", "comparePointers"},
{"a5-1-4", "returnDanglingLifetime"},
{"a5-2-2", "cstyleCast"},
{"a5-2-5", "arrayIndexOutOfBounds,arrayIndexOutOfBoundsCond,pointerOutOfBounds,pointerOutOfBoundsCond,negativeIndex,arrayIndexThenCheck,bufferAccessOutOfBounds,objectIndex,argumentSize"},
{"m5-3-4", "sizeofFunctionCall"},
{"a5-3-2", "nullPointer,nullPointerRedundantCheck,nullPointerArithmetic,nullPointerArithmeticRedundantCheck,nullPointerDefaultArg"},
Expand Down Expand Up @@ -99,13 +98,13 @@ std::vector<checkers::IdMapping> checkers::idMappingCertCpp{
{"CTR51", "eraseDereference"},
{"CTR54", "comparePointers"},
{"CTR55", "containerOutOfBounds"},
{"DCL57", "deallocThrow,exceptThrowInDestructor"},
{"DCL57", "exceptDeallocThrow,exceptThrowInDestructor"},
{"DCL60", "ctuOneDefinitionRuleViolation"},
{"ERR57", "memleak"},
{"EXP52", "sizeofCalculation"},
{"EXP53", "uninitvar,uninitdata,uninitStructMember"},
{"EXP54", "uninitvar,danglingLifetime,danglingReference,danglingTemporaryLifetime,danglingTempReference,returnDanglingLifetime"},
{"EXP61", "danglingLifetime,danglingReference,danglingTemporaryLifetime,danglingTempReference,returnDanglingLifetime"},
{"EXP61", "danglingLifetime,danglingReference,danglingTemporaryLifetime,danglingTempReference,returnDanglingLifetime,deallocuse,deallocret"},
{"EXP63", "accessMoved"},
{"FIO50", "IOWithoutPositioning"},
{"MEM50", "deallocuse"},
Expand All @@ -124,7 +123,7 @@ std::vector<checkers::IdMapping> checkers::idMappingMisraC{
{"1.1", "syntaxError"},
{"1.3", "error"},
{"2.1", "duplicateBreak,unreachableCode"},
{"2.2", "constStatement,redundantCondition,redundantAssignment,redundantAssignInSwitch,unreadVariable"},
{"2.2", "constStatement,redundantCondition,redundantAssignment,redundantAssignInSwitch,unreadVariable,unusedFunction"},
{"2.6", "unusedLabel"},
{"2.8", "unusedVariable"},
{"5.3", "shadowVariable"},
Expand Down Expand Up @@ -168,7 +167,7 @@ std::vector<checkers::IdMapping> checkers::idMappingMisraCpp2008{
{"5-0-16", "pointerOutOfBounds"},
{"5-0-17", "comparePointers"},
{"5-0-18", "comparePointers"},
{"5-2-4", "cstyleCast"},
{"5-2-4", "cstyleCast,dangerousTypeCast"},
{"5-3-4", "sizeofFunctionCall"},
{"5-8-1", "shiftTooManyBits"},
{"6-6-5", "missingReturn"},
Expand Down
2 changes: 1 addition & 1 deletion lib/checkexceptionsafety.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void CheckExceptionSafety::destructorsError(const Token * const tok, const std::

void CheckExceptionSafety::deallocThrow()
{
if (!mSettings->severity.isEnabled(Severity::warning))
if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("exceptDeallocThrow"))
return;

logChecker("CheckExceptionSafety::deallocThrow"); // warning
Expand Down
2 changes: 1 addition & 1 deletion lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ void CheckOther::warningDangerousTypeCast()
// Only valid on C++ code
if (!mTokenizer->isCPP())
return;
if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("cstyleCast"))
if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("dangerousTypeCast"))
return;

logChecker("CheckOther::warningDangerousTypeCast"); // warning,c++
Expand Down
43 changes: 39 additions & 4 deletions lib/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ static const std::set<std::string> autosarCheckers{
"bufferAccessOutOfBounds",
"comparePointers",
"constParameter",
"cstyleCast",
"ctuOneDefinitionRuleViolation",
"doubleFree",
"duplInheritedMember",
Expand Down Expand Up @@ -396,7 +395,6 @@ static const std::set<std::string> autosarCheckers{
"unsignedLessThanZero",
"unusedFunction",
"unusedStructMember",
"unusedValue",
"unusedVariable",
"useInitializationList",
"variableScope",
Expand Down Expand Up @@ -459,32 +457,65 @@ static const std::set<std::string> certCCheckers{
static const std::set<std::string> certCppCheckers{
"IOWithoutPositioning",
"accessMoved",
"argumentSize",
"arrayIndexOutOfBounds",
"arrayIndexOutOfBoundsCond",
"arrayIndexThenCheck",
"autoVariables",
"autovarInvalidDeallocation",
"bitwiseOnBoolean",
"bufferAccessOutOfBounds",
"comparePointers",
"containerOutOfBounds",
"ctuOneDefinitionRuleViolation",
"danglingLifetime",
"danglingReference",
"danglingTempReference",
"danglingTemporaryLifetime",
"deallocThrow",
"deallocret",
"deallocuse",
"doubleFree",
"eraseDereference",
"exceptDeallocThrow",
"exceptThrowInDestructor",
"floatConversionOverflow",
"initializerList",
"integerOverflow",
"invalidContainer",
"invalidFunctionArg",
"invalidLengthModifierError",
"invalidLifetime",
"invalidScanfFormatWidth",
"invalidscanf",
"leakReturnValNotUsed",
"leakUnsafeArgAlloc",
"memleak",
"memleakOnRealloc",
"mismatchAllocDealloc",
"missingReturn",
"negativeIndex",
"nullPointer",
"nullPointerArithmetic",
"nullPointerArithmeticRedundantCheck",
"nullPointerDefaultArg",
"nullPointerRedundantCheck",
"objectIndex",
"operatorEqToSelf",
"pointerOutOfBounds",
"pointerOutOfBoundsCond",
"preprocessorErrorDirective",
"resourceLeak",
"returnDanglingLifetime",
"sizeofCalculation",
"stringLiteralWrite",
"uninitStructMember",
"uninitdata",
"uninitvar",
"useClosedFile",
"virtualCallInConstructor",
"virtualDestructor"
"virtualDestructor",
"wrongPrintfScanfArgNum",
"wrongPrintfScanfParameterPositionError"
};

static const std::set<std::string> misrac2012Checkers{
Expand Down Expand Up @@ -524,6 +555,7 @@ static const std::set<std::string> misrac2012Checkers{
"unknownEvaluationOrder",
"unreachableCode",
"unreadVariable",
"unusedFunction",
"unusedLabel",
"unusedVariable",
"useClosedFile",
Expand Down Expand Up @@ -567,6 +599,7 @@ static const std::set<std::string> misrac2023Checkers{
"unknownEvaluationOrder",
"unreachableCode",
"unreadVariable",
"unusedFunction",
"unusedLabel",
"unusedVariable",
"useClosedFile",
Expand Down Expand Up @@ -610,6 +643,7 @@ static const std::set<std::string> misrac2025Checkers{
"unknownEvaluationOrder",
"unreachableCode",
"unreadVariable",
"unusedFunction",
"unusedLabel",
"unusedVariable",
"useClosedFile",
Expand All @@ -623,6 +657,7 @@ static const std::set<std::string> misracpp2008Checkers{
"constVariable",
"cstyleCast",
"ctuOneDefinitionRuleViolation",
"dangerousTypeCast",
"danglingLifetime",
"duplInheritedMember",
"duplicateBreak",
Expand Down
Loading