Skip to content

Add MISRA C++:2023 warning features for gcc and clang - #43

Open
nradakovic wants to merge 1 commit into
mainfrom
nira_add_misra_2023
Open

nradakovic wants to merge 1 commit into
mainfrom
nira_add_misra_2023

Conversation

@nradakovic

Copy link
Copy Markdown
Member

Introduce cc_feature targets (misra_cpp_2023_warnings) with the compiler warnings listed in the S-CORE MISRA C++:2023 Guideline Enforcement Plan. Warnings are scoped to C++ compile actions only, since several flags are invalid for C. clang-tidy checks are intentionally left out; their integration will be handled separately via the clang_tidy policy module.

resolves #42

@nradakovic nradakovic self-assigned this Sep 15, 2026
@nradakovic nradakovic added enhancement New feature or request p3 Medium/Low - handle it within normal process compiler warnings Compiler warnings feature add or update. labels Sep 15, 2026
@nradakovic
nradakovic marked this pull request as ready for review September 15, 2026 10:36
Copilot AI lite review requested due to automatic review settings September 15, 2026 10:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Both reviewed files have unresolved moderate findings requiring documentation or validation updates.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds compiler-specific Bazel features for MISRA C++:2023 warning diagnostics, scoped to C++ compilation actions.

Changes:

  • Adds GCC and Clang warning mappings.
  • Exposes misra_cpp_2023_warnings feature targets.
  • Omits clang-tidy integration for separate handling.
File summaries
File Summary
warnings/gcc/features/misra_cpp_2023/BUILD Defines GCC warning arguments and feature. Moderate documentation issue remains (3 votes), including GEP traceability and partial-enforcement limitations.
warnings/clang/features/misra_cpp_2023/BUILD Defines Clang warning arguments and feature. Moderate validation issue remains (3 votes); representative compile and C compatibility tests are needed.
Review details

Suppressed comments (1)

warnings/gcc/features/misra_cpp_2023/BUILD:55

  • This adds a public GCC feature, but the repository's existing warning test infrastructure never registers or enables it. Without a representative GCC positive/negative compile test (and a C target proving these C++-only args do not affect C actions), an invalid flag or incorrect feature/action wiring can pass review unnoticed. Add the feature to a dedicated test toolchain/config and exercise the expected diagnostics in CI.
cc_feature(
    name = "misra_cpp_2023",
    args = ["@score_cpp_policies//warnings/gcc/features/misra_cpp_2023:args"],
    feature_name = "misra_cpp_2023_warnings",
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread warnings/clang/features/misra_cpp_2023/BUILD
Comment thread warnings/gcc/features/misra_cpp_2023/BUILD
Introduce cc_feature targets (misra_cpp_2023_warnings) with the compiler
warnings listed in the S-CORE MISRA C++:2023 Guideline Enforcement Plan.
Warnings are scoped to C++ compile actions only, since several flags are
invalid for C. clang-tidy checks are intentionally left out; their
integration will be handled separately via the clang_tidy policy module.

resolves #42
Comment thread docs/warnings.md
| `-Wuninitialized` | Warn about variables used before being initialized on some code path. |
| `-Wduplicate-enum` | Warn about two enumerators in the same enum sharing the same value where it looks unintentional. |
| `-Winconsistent-missing-destructor-override` | Warn when a class overrides a base class's virtual destructor without marking its own `override`. |
| `-Winconsistent-missing-override` | Warn when a virtual function overrides a base-class member but isn't itself marked `override`. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity was -Wsuggest-destructor-override ruled out?
It complements -Winconsistent-missing-override.

class Base {
public:
    // Added {} here so the function has an implementation
    virtual void doSomething() {}; 
    virtual ~Base() {};
};

class Derived : public Base {
public:
    void doSomething() override { };  // Uses override here!
    ~Derived() {};                    // Missing override here!
};

int main() {
    Derived d;
}

complied with just -std=c++17 -Winconsistent-missing-override

does not produce the warning.

<source>:11:5: warning: '~Derived' overrides a destructor but is not marked 'override' [-Wsuggest-destructor-override]
   11 |     ~Derived() {};                    // Missing override here!

Can be tested here -> https://godbolt.org/z/zj5bzqshz

@paulquiring paulquiring Sep 22, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It helps with "Rule 13.3.1 User-declared member functions shall use the virtual, override and final specifiers appropriately."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler warnings Compiler warnings feature add or update. enhancement New feature or request p3 Medium/Low - handle it within normal process

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Add 1st draft of the compiler warning set required to support MISRA C++:2023 compliance.

3 participants