Everything

-misra2012 [Professional Edition only] [V2.04.00 or later]


< Compile Options / Source Options >

[Format]

-misra2012 = {
   all
   | apply=<rule number>[,...]
   | ignore=<rule number>[,...]
   | required
   | required_add=<rule number>[,...]
   | required_remove=<rule number>[,...]
   | <filename> }

[Description]

-

This option enables checking against the MISRA-C:2012 rules and to select specific rules to be used.

-

When misra2012=all, the compiler checks the source code against all of the rules that are supported.

-

When misra2012=apply=<rule number>[,<rule number>,...], the compiler checks the source code against the rules with the selected numbers.

-

When misra2012=ignore=<rule number>[,<rule number>,...], the compiler checks the source code against the rules other than those with the selected numbers.

-

When misra2012=required, the compiler checks the source code against the rules of the "mandatory" and "required" types.

-

When misra2012=required_add=<rule number>[,<rule number>,...], the compiler checks the source code against the rules of the "mandatory" and "required" types and the rules with the selected numbers.

-

When misra2012=required_remove=<rule number>[,<rule number>,...], the compiler checks the source code against the rules other than those with the selected numbers among the rules of the "required" type.

-

When misra2012=<filename>, the compiler checks the source code against the rules with the numbers written in the specified file. One rule number is written per line in the file. Each rule number must be specified by using decimal values and a period (".").

-

When checking of a line of code against the MISRA-C:2012 rules leads to detection of a violation, a message in the following format will appear.

<Filename> (<line number>): M0523086 <Rule number>: <Message>

-

When -misra2012=<filename> is used more than once, only the last specification is valid.

[Remarks]

-

The -misra2012 option can be specified more than once. However, if multiple types exist, only the type written last and consecutive specifications of the same type are valid.

... -misra2012=ignore=3.1

-misra2012=required_add=4.1 -misra2012=apply=4.2

-misra2012=apply=5.2 ...

In this example, ignore, apply, and required_add are specified, but only apply (used in the last two cases) is valid. The compiler will check the source code against rules 4.2 and 5.2.

-

When the number of an unsupported rule is specified for <rule number>, the compiler detects error F0523031 and stops the processing.

-

When the file specified in misra2012=<filename> cannot be opened, the compiler detects error F0523029. When rule numbers are not extractable from the specified file, the compiler detects error F0523030. Processing by the compiler stops in both cases.

-

This option is ignored when cpp or ecpp is selected for the lang option or when output=prep is specified at the same time.

-

If this option is specified together with lang=c99, checking against C90/C99 common rules is performed in the scope of C99.

-

For source programs that use extended functions such as #pragma, checking against these rules are suppressed under some conditions. For details, refer to the section on the check_language_extension option.

-

MISRA diagnostic messages displayed by the misra2012 option cannot be controlled by the change_message option.

-

Checking the source code cannot be simultaneously checked against the MISRA-C:2004 rules.

-

In V3.02.00 and later versions, this option supports the MISRA-C: 2012 rules listed below.
2.2 2.6 2.7

3.1 3.2

4.1 4.2

5.1(*2) 5.2 5.3 5.4 5.5 5.6(*2) 5.7(*2) 5.8(*2) 5.9(*2)

6.1 6.2

7.1 7.2 7.3 7.4

8.1 8.2 8.3(*2) 8.4 8.5(*3) 8.6(*3) 8.8 8.9 8.11 8.12 8.13 8.14

9.1 9.2 9.3 9.4 9.5

10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8

11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9

12.1 12.2 12.3 12.4 12.5

13.1 13.2 13.3 13.4 13.5 13.6

14.2 14.3 14.4

15.1 15.2 15.3 15.4 15.5 15.6 15.7

16.1 16.2 16.3 16.4 16.5 16.6 16.7

17.1 17.3 17.4 17.5 17.6 17.7 17.8

18.4 18.5 18.7

19.2

20.1 20.2 20.3 20.4 20.5 20.6 20.7 20.8 20.9 20.10 20.11 20.12 20.13 20.14

21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8(*1) 21.9 21.10 21.11 21.12

 

*1) Checking is in accord with to MISRA C:2012, Amendment 1 (getenv is not checked).

*2) If the -misra_intermodule option is specified, analysis can be performed over multiple files.

*3) This rule is valid only when the -misra_intermodule option is specified.

[Example]

-

In this example, tree types of -misra2012 option (ignore, apply, and required_add) are specified, but only apply in the last two consecutive specifications is valid. As a result, the compiler checks the source code against rules 4.2 and 5.2.

-misra2012=ignore=3.1
-misra2012=required_add=4.1 -misra2012=apply=4.2
-misra2012=apply=5.2