of 6
Jan. 16, 2019
2. Point for caution when the -Xmisra2012 option is specified. (No.24)
2.1 Applicable Products
CC-RH V1.04.00 to V2.00.00 [Professional edition] (Rule 16.1 and 16.4)
CC-RH V1.07.00 to V2.00.00 [Professional edition] (Rule 15.6, 15.7, 16.1, and 16.2)
2.2 Details
When checking source code against MISRA-C:2012 rules by specifying -Xmisra2012 option, the compiler may
output a message for a code which does not violate the rules and may not output a message for a code which violates
the rules.
MISRA-C is a set of software development guidelines whose purpose is to maintain the safety, portability and
reliability of embedded systems programmed in the C language.
2.3 Conditions
An error occurs when the following rule numbers are specified to be checked.
⚫ Rule 15.6
No message is output for a code that violates the rule if the -lang=c99 option is specified.
⚫ Rule 15.7
No message is output for a code that violates the rule if the -lang=c99 option is specified.
⚫ Rule 16.1
No message is output for a code that violates the rule if all of the following conditions are met:
(1) “{“ is written immediately after a switch statement (controlling expression).
(2) Both a case clause and a default clause are written in the switch statement (1).
(3) Each case clause and default clause in (2) ends with a break statement or a compound statement
(Note1)
(block) which includes a break statement at the end.
(4) At least one of the case clauses or default clauses in (3) meets all the conditions below.
(4-1) A compound statement (block) which is neither a selection statement (if or switch) nor a repeat
statement (while, do-while, or for) is written at the end.
(4-2) A statement is written before the compound statement (block) in (4-1).
Note 1: A compound statement is a statement enclosed with “{ }”. An if statement enclosed with “{ }”
is also a compound statement.
⚫ Rule 16.2
No message is output for a code that violates the rule if all of the following conditions are met.
(1) The -lang=c99 option is specified.
(2) A case or default label is written immediately after switch (controlling expression) without “{”.
⚫ Rule 16.4
A message may be output for a code that does not violate the rule if either of the following conditions is met:
(1) -lang=c is specified and a compound statement (block) is written in the function definition.
(2) -lang=c99 is specified, and a compound statement (block), selection statement (if or switch), or repeat
statement (while, do-while, or for) is written in the function definition.
This includes a case where a selection statement or repeat statement is written without “{ }”.