Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds MISRA C++:2023 coverage for additional declaration rules by introducing RULE-6-2-2 and RULE-6-7-1 queries, and refactors CERT DCL40-C to reuse new shared implementations with updated/expanded tests.
Changes:
- Added MISRA C++:2023 queries for RULE-6-2-2 (incompatible declarations) and RULE-6-7-1 (local static storage duration).
- Introduced shared C++ rule implementations for incompatible object/function declarations and wired them into MISRA/CERT queries and exclusion metadata.
- Updated/added tests and test references to validate the new shared implementations across C, C++, MISRA, and CERT.
Reviewed changes
Copilot reviewed 41 out of 43 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| rules.csv | Adjusts rule-to-package mapping for MISRA C++:2023 rules touched by this PR. |
| rule_packages/cpp/Declarations2.json | Adds rule-package metadata for new MISRA C++:2023 queries (RULE-6-2-2, RULE-6-7-1). |
| rule_packages/c/Declarations2.json | Adds shared-implementation metadata fields to align C rule packaging with shared implementations. |
| cpp/misra/test/rules/RULE-6-7-1/test.cpp | New unit test for local static-storage-duration rule behavior. |
| cpp/misra/test/rules/RULE-6-7-1/LocalVariableStaticStorageDuration.qlref | Test harness reference for the RULE-6-7-1 query. |
| cpp/misra/test/rules/RULE-6-7-1/LocalVariableStaticStorageDuration.expected | Expected results for RULE-6-7-1 test. |
| cpp/misra/test/rules/RULE-6-2-2/IncompatibleObjectDeclarationsCpp.testref | Points RULE-6-2-2 object-declaration test to shared/common tests. |
| cpp/misra/test/rules/RULE-6-2-2/IncompatibleObjectDeclarations.testref | Additional test reference for shared object-declaration tests. |
| cpp/misra/test/rules/RULE-6-2-2/IncompatibleFunctionDeclarationsCpp.testref | Points RULE-6-2-2 function-declaration test to shared/common tests. |
| cpp/misra/test/rules/RULE-6-2-2/IncompatibleFunctionDeclarations.testref | Additional test reference for shared function-declaration tests. |
| cpp/misra/src/rules/RULE-6-7-1/LocalVariableStaticStorageDuration.ql | New MISRA C++:2023 RULE-6-7-1 query implementation. |
| cpp/misra/src/rules/RULE-6-2-2/IncompatibleObjectDeclarationsCpp.ql | New MISRA C++:2023 RULE-6-2-2 object-declaration query using shared module. |
| cpp/misra/src/rules/RULE-6-2-2/IncompatibleFunctionDeclarationsCpp.ql | New MISRA C++:2023 RULE-6-2-2 function-declaration query using shared module. |
| cpp/common/test/rules/incompatibleobjectdeclaration/test1.cpp | New shared C++ test input for incompatible object declarations. |
| cpp/common/test/rules/incompatibleobjectdeclaration/test.cpp | New shared C++ test input for incompatible object declarations. |
| cpp/common/test/rules/incompatibleobjectdeclaration/IncompatibleObjectDeclaration.ql | Generated test query wiring for shared object-declaration logic. |
| cpp/common/test/rules/incompatibleobjectdeclaration/IncompatibleObjectDeclaration.expected | Expected results for shared C++ object-declaration tests. |
| cpp/common/test/rules/incompatiblefunctiondeclaration/test1.cpp | New shared C++ test input for incompatible function declarations. |
| cpp/common/test/rules/incompatiblefunctiondeclaration/test.cpp | New shared C++ test input for incompatible function declarations. |
| cpp/common/test/rules/incompatiblefunctiondeclaration/IncompatibleFunctionDeclaration.ql | Generated test query wiring for shared function-declaration logic. |
| cpp/common/test/rules/incompatiblefunctiondeclaration/IncompatibleFunctionDeclaration.expected | Expected results for shared C++ function-declaration tests. |
| cpp/common/src/codingstandards/cpp/rules/incompatibleobjectdeclaration/IncompatibleObjectDeclaration.qll | Adds shared configurable implementation for incompatible object declarations. |
| cpp/common/src/codingstandards/cpp/rules/incompatiblefunctiondeclaration/IncompatibleFunctionDeclaration.qll | Adds shared configurable implementation for incompatible function declarations. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll | Registers the new Declarations2 package in C++ exclusion metadata. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Declarations2.qll | New autogenerated exclusion/metadata wrapper for the Declarations2 C++ package queries. |
| change_notes/2026-03-27-update-compatible-objects-DCL40-C.md | Adds a change note for DCL40-C behavior/results adjustments. |
| c/common/test/rules/incompatibleobjectdeclaration/test1.c | New shared C test input for incompatible object declarations. |
| c/common/test/rules/incompatibleobjectdeclaration/test.c | New shared C test input for incompatible object declarations. |
| c/common/test/rules/incompatibleobjectdeclaration/IncompatibleObjectDeclaration.ql | Generated test query wiring for shared object-declaration logic (C tests). |
| c/common/test/rules/incompatibleobjectdeclaration/IncompatibleObjectDeclaration.expected | Expected results for shared C object-declaration tests. |
| c/common/test/rules/incompatiblefunctiondeclaration/test1.c | New shared C test input for incompatible function declarations. |
| c/common/test/rules/incompatiblefunctiondeclaration/test.c | New shared C test input for incompatible function declarations. |
| c/common/test/rules/incompatiblefunctiondeclaration/IncompatibleFunctionDeclaration.ql | Generated test query wiring for shared function-declaration logic (C tests). |
| c/common/test/rules/incompatiblefunctiondeclaration/IncompatibleFunctionDeclaration.expected | Expected results for shared C function-declaration tests. |
| c/cert/test/rules/DCL40-C/IncompatibleObjectDeclarations.testref | Retargets CERT DCL40-C object-declaration tests to shared common tests. |
| c/cert/test/rules/DCL40-C/IncompatibleFunctionDeclarations.testref | Retargets CERT DCL40-C function-declaration tests to shared common tests. |
| c/cert/src/rules/DCL40-C/IncompatibleObjectDeclarations.ql | Refactors CERT DCL40-C object-declaration query to use shared implementation. |
| c/cert/src/rules/DCL40-C/IncompatibleFunctionDeclarations.ql | Refactors CERT DCL40-C function-declaration query to use shared implementation. |
| c/cert/src/rules/DCL40-C/ExternalIdentifiers.qll | Removes the now-redundant CERT-specific ExternalIdentifiers helper. |
Comments suppressed due to low confidence (1)
c/cert/src/rules/DCL40-C/IncompatibleObjectDeclarations.ql:7
- The CodeQL query metadata tag is malformed (
@ kind). This will likely prevent the query kind from being parsed correctly. Please change it to the standard@kind problem(no space after@).
* types, then accessing those objects can lead to undefined behaviour.
* @kind problem
* @precision high
...rc/codingstandards/cpp/rules/incompatibleobjectdeclaration/IncompatibleObjectDeclaration.qll
Show resolved
Hide resolved
...odingstandards/cpp/rules/incompatiblefunctiondeclaration/IncompatibleFunctionDeclaration.qll
Show resolved
Hide resolved
MichaelRFairhurst
requested changes
Mar 30, 2026
Collaborator
MichaelRFairhurst
left a comment
There was a problem hiding this comment.
Nice! Way to find some high bang-for-the-buck improvements along the way here.
...rc/codingstandards/cpp/rules/incompatibleobjectdeclaration/IncompatibleObjectDeclaration.qll
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add rule RULE-6-2-2 and translate to a shared rule with DCL40-C, improve testing based on cpp nuances
Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
Release change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.