RENESAS TOOL NEWS
R20TS0394EJ0100 Rev.1.00 Page
1
of 4
Jan. 16, 2019
[Notes]
C Compiler Package for RL78 Family
Outline
When using the C compiler package for RL family CC-RL, note the following points:
1. Point for caution when the -misra2012 option is specified. (CCRL#023)
Note: The number following the note is an identifying number for the precautionary note.
1. Point for caution when the -misra2012 option is specified. (CCRL#023)
1.1 Applicable Products
CC-RL V1.03.00 to V1.07.00 [Professional edition] (Rule 16.1 and 16.4)
CC-RL V1.06.00 to V1.07.00 [Professional edition] (Rule 15.6, 15.7, and 16.2)
1.2 Details
When checking source code against MISRA-C:2012 rules by specifying -misra2012 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.
1.3 Conditions
An error occurs when the following rules are specified.
Rule 15.6
No message is output for a code which violates the rule if the -lang=c99 option is specified.
Rule 15.7
No message is output for a code which 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).
R20TS0394EJ0100
Rev.1.00
Jan. 16, 2019
RENESAS TOOL NEWS
R20TS0394EJ0100 Rev.1.00 Page
2
of 4
Jan. 16, 2019
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 “{ }”.
Note: A compound statement refers to a statement enclosed with “{ }”. An if statement enclosed with “{ }” is also a
compound statement.
1.4 Example
The example of an error is shown below. Characters in red are the parts corresponding to the conditions.
[C source code] (rule 16.1)
Although the C source code above violates rule 16.1 of MISRA C: 2012, no message is output.
Lines 3 and 12: Condition (1) is met because “{” is written immediately after switch (controlling expression).
Lines 4 and 10: Condition (2) is met because both a case clause and a default clause are written.
Lines 8 and 11: Condition (3) is met because the case clause and default clause end with a break statement.
Lines 6 and 9: Condition (4-1) is met because the case clause ends with a compound statement (block).
Line 5: Condition (4-2) is met because a statement is written before a compound statement (block).
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
int x;
void func(void) {
switch(x) { // Condition (1)
case 1: // Condition (2)
++x; // Condition (4-2)
{ // Condition (4-1)
--x;
break; // Condition (3)
} // Condition (4-1)
default: // Condition (2)
break; // Condition (3)
} // Condition (1)
}
RENESAS TOOL NEWS
R20TS0394EJ0100 Rev.1.00 Page
3
of 4
Jan. 16, 2019
[C source code] (rule 16.2)
The C source code above violates rule 16.2 of MISRA C:2012. Although a message is output when -lang=c is specified,
no message is output when -lang=c99 is specified.
Lines 3 and 4: Condition (2) is met because a case label is written without “{” immediately after switch (controlling
expression).
1.5 Workaround
There is no workaround for this problem.
1.6 Schedule for Fixing the Problem
This problem is fixed in CC-RL V1.08.00. (Scheduled to be released on January 21.)
1:
2:
3:
4:
5:
6:
int x;
void func(void) {
switch(x) // Condition (2)
case 1: // Condition (2)
break;
}
RENESAS TOOL NEWS
R20TS0394EJ0100 Rev.1.00 Page
4
of 4
Jan. 16, 2019
Revision History
Rev.
Date
Page
Summary
1.00
Jan. 16, 2019
-
First edition issued
TOYOSU FORESIA, 3-2-24 Toyosu, Koto-ku, Tokyo 135-0061 Japan
Renesas Electronics Corporation
■Inquiry
https://www.renesas.com/contact/
Renesas Electronics has used reasonable care in preparing the information included in this document,
but Renesas Electronics does not warrant that such information is error free. Renesas Electronics
assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions
from the information included herein.
The past news contents have been based on information at the time of publication. Now changed or
invalid information may be included.
The URLs in the Tool News also may be subject to change or become invalid without prior notice.
All trademarks and registered trademarks are the property of their respective owners.
© 2019 Renesas Electronics Corporation. All rights reserved.
TS Colophon 2.2