Initial implementation of rule 4-1-1, must be standard C++17#1106
Merged
MichaelRFairhurst merged 10 commits intomainfrom Apr 17, 2026
Merged
Initial implementation of rule 4-1-1, must be standard C++17#1106MichaelRFairhurst merged 10 commits intomainfrom
MichaelRFairhurst merged 10 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds the initial CodeQL implementation for MISRA C++:2023 RULE-4-1-1 (“must be standard C++17”) by modeling several common compiler-language extensions and wiring the rule into the toolchain package and test suite.
Changes:
- Introduces a new rule query (
CompilerLanguageExtensionsUsed) and a shared library model of C++ compiler extensions. - Adds a dedicated unit test directory with a
.qlrefand.expectedresults for RULE-4-1-1. - Wires the rule into
Toolchain2packaging/metadata and updates standard-library test stubs needed by the test.
Show a summary per file
| File | Description |
|---|---|
| rule_packages/cpp/Toolchain2.json | Adds MISRA-C++-2023 RULE-4-1-1 metadata and query descriptor in Toolchain2 package. |
| cpp/misra/src/rules/RULE-4-1-1/CompilerLanguageExtensionsUsed.ql | New rule query selecting detected compiler extensions and reporting messages. |
| cpp/common/src/codingstandards/cpp/Extensions.qll | Adds the core modeling of C++ compiler extensions and associated alert messages. |
| cpp/misra/test/rules/RULE-4-1-1/test.cpp | New test cases covering attributes, builtins, statement expressions, pragmas, etc. |
| cpp/misra/test/rules/RULE-4-1-1/CompilerLanguageExtensionsUsed.qlref | Test reference to the production query. |
| cpp/misra/test/rules/RULE-4-1-1/CompilerLanguageExtensionsUsed.expected | Expected results for the test query execution. |
| cpp/common/test/includes/standard-library/type_traits.h | Extends the type-traits stub to support test compilation. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/Toolchain2.qll | Autogenerated Toolchain2 query metadata wrapper for exclusions. |
| cpp/common/src/codingstandards/cpp/exclusions/cpp/RuleMetadata.qll | Registers Toolchain2 metadata with the exclusions framework. |
Copilot's findings
Comments suppressed due to low confidence (2)
cpp/common/src/codingstandards/cpp/Extensions.qll:126
- Some message strings exceed the repo's 100-character line limit for CodeQL source/test files (for example, this line). Please wrap these strings across multiple lines to keep each source line ≤ 100 characters.
override string getMessage() {
result =
"Extended floating-point types are a compiler extension and are not portable to other compilers."
}
cpp/common/src/codingstandards/cpp/Extensions.qll:203
CPPPreprocessorDirectiveExtensionis a new public class (not markedprivate) but it does not have a QLDoc comment. Add QLDoc (or mark itprivate/ document it as INTERNAL) to satisfy the project's documentation requirements for public declarations.
class CPPPreprocessorDirectiveExtension extends CPPCompilerExtension, PreprocessorDirective {
string kind;
CPPPreprocessorDirectiveExtension() {
this instanceof PreprocessorPragma and kind = "#pragma " + getHead()
or
- Files reviewed: 9/9 changed files
- Comments generated: 8
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
mbaluda
approved these changes
Apr 15, 2026
Collaborator
mbaluda
left a comment
There was a problem hiding this comment.
LGTM!
Suggested an improvement to the error message
Corrected spelling of 'preceding' in warning message.
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
please enter the description of your change here
Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
RULE-4-1-1Release 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.