Main Content

Check MISRA C:2012 (-misra3)

Check for violations of MISRA C:2012 rules and directives

Description

Specify whether to check for violations of MISRA C™:2012 guidelines1 Each value of the option corresponds to a subset of guidelines to check.

Set Option

User interface (desktop products only): In your project configuration, the option is on the Coding Standards & Code Metrics node. See Dependencies for other options that you must also enable.

User interface (Polyspace Platform, desktop products only): This option does not exist in the project configuration. Activate checkers by using the options Use custom checkers file and Checkers activation file (-checkers-activation-file).

Command line and options file: Use the option -misra3. See Command-Line Information.

Why Use This Option

Use this option to specify the subset of MISRA C:2012 rules to check for.

After analysis, the Results List pane lists the coding standard violations. On the Source pane, for every coding rule violation, Polyspace® assigns a symbol to the keyword or identifier relevant to the violation.

Settings

Default: mandatory-required

mandatory

Check for mandatory guidelines.

mandatory-required

Check for mandatory and required guidelines.

  • Mandatory guidelines: Your code must comply with these guidelines.

  • Required guidelines: You may deviate from these guidelines. However, you must complete a formal deviation record, and your deviation must be authorized.

    See Section 5.4 of the MISRA C:2012 guidelines. For an example of a deviation record, see Appendix I of the MISRA C:2012 guidelines.

Note

To turn off some required guidelines, instead of mandatory-required select custom. To clear specific guidelines, click . In the Comment column, enter your rationale for disabling a guideline. For instance, you can enter the Deviation ID that refers to a deviation record for the guideline. The rationale appears in your generated report.

single-unit-rules

Check a subset of rules that apply only to single translation units. These rules are checked in the compilation phase of the analysis.

system-decidable-rules

Check rules in the single-unit-rules subset and some rules that apply to the collective set of program files. The additional rules are the less complex rules that apply at the integration level. These rules can be checked only at the integration level because the rules involve more than one translation unit. These rules are checked in the compilation and linking phases of the analysis.

all

Check for mandatory, required, and advisory guidelines.

SQO-subset1

Check for only a subset of guidelines. For more information, see Software Quality Objective Subsets for MISRA Coding Standards.

SQO-subset2

Check for the subset SQO-subset1, plus some additional rules. For more information, see Software Quality Objective Subsets for MISRA Coding Standards.

from-file

Specify an XML file where you configure a custom selection of checkers for this coding standard. To create a configuration file, click , then select the rules and recommendations you want to check for this coding standard from the right pane of the Checkers selection window. Save the file.

To use or update an existing configuration file, in the Checkers selection window, enter the full path to the file in the field provided or click Browse.

If you set the option to from-file, enable Set checkers by file (-checkers-selection-file).

Dependencies

  • This option is available only if you set Source code language (-lang) to C or C-CPP.

    For projects with mixed C and C++ code, the MISRA C:2012 checker analyzes only .c files.

  • If you set Source code language (-lang) to C-CPP, you can activate a C coding rule checker and a C++ coding rule checker. When you have both C and C++ coding rule checkers active, to avoid duplicate results, Polyspace does not produce the C coding rules found in the linking phase (such as MISRA C:2012 Rule 8.3).

Tips

Command-Line Information

Use the command -misra3 in the command line to check for violations of MISRA C:2012 rules.

Parameter: -misra3
Value: mandatory | mandatory-required | single-unit-rules | system-decidable-rules | all | SQO-subset1 | SQO-subset2 | from-file
Example (Bug Finder): polyspace-bug-finder -lang c -sources file_name -misra3 mandatory-required
Example (Bug Finder Server): polyspace-bug-finder-server -lang c -sources file_name -misra3 mandatory-required

Alternatively, enable all or specific MISRA C:2012 rules through a checkers activation XML file. See Checkers activation file (-checkers-activation-file).

Version History

expand all


1 MISRA™ and MISRA C are registered trademarks of MIRA Ltd., held on behalf of the MISRA Consortium.