TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
ASML C Coding Standard
Search

Category: Statement and Blocks

Synopsis:Rules about statements


Description:

A statement specifies an action to be performed. Except as indicated, statements are executed in sequence. A block allows a set of declarations and statements to be grouped into one syntactic unit.

Coding Rules

NameCheckedSynopsis
6.8.a Checked automatically with code checker All control statements shall be fully brace enclosed. This means that all "if", "while", "for", "do" and "switch" statements are followed by a brace-enclosed compound statement.
6.8.c Checked automatically with code checker Any statement that is logically never executed shall not occur in the source code.
6.8.d Checked automatically with code checker Avoid magic numbers.
6.8.1.a Checked automatically with code checker Statements shall not be labelled except for "case" and "default" in a switch-statement.
6.8.3.a Checked automatically with code checker Each expression and statement shall have an effect.
6.8.3.b Checked automatically with code checker A null statement (;) shall not be used.
6.8.4.b Checked automatically with code checker The condition (or guard) of a selective alternative shall be a logical operator, an equality operator or a relational expression (and not be an assignment). Exception is made for boolean type. For boolean type no relational expression is required.
6.8.4.c The termination condition of iterations shall be of type boolean.
6.8.4.1.b Checked automatically with code checker N-ary selection constructs programmed using "if ... else if ..." shall have an "else" clause.
6.8.4.2.a Checked automatically with code checker The switch expression shall not contain any logical expression (one or more of the ">", ">=", "<", "<=", "==", "!=", "&&", "||" or "!" operators).
6.8.4.2.b Checked automatically with code checker "switch" statements shall have one and only one "default" clause.
6.8.4.2.c Checked automatically with code checker Each non empty case clause and default clause shall end with a break statement.
6.8.4.2.d Checked automatically with code checker The default clause shall be the last entry in the switch statement.
6.8.4.2.e Checked automatically with code checker Make sure all code in a switch statement serves a purpose.
6.8.5.a Checked automatically with code checker The termination condition of iteration shall not have a constant value.
6.8.5.1.a Checked automatically with code checker The variables used in expression 2 of a "for" loop shall not be changed in the loop body and expression 3 at the same time.
6.8.5.1.c Checked automatically with code checker The loop variable of a for loop shall be used in the loop body.
6.8.6.1.a Checked automatically with code checker The "goto" statement shall not be used.
6.8.6.2.a Checked automatically with code checker The "continue" statement shall not be used.
6.8.6.3.a Checked automatically with code checker The break statement shall not be used to exit from an iteration statement ("for" or "while").
6.8.6.4.a Checked automatically with code checker There shall be exactly one "return" statement in a function returning non-void.
6.8.6.4.b Checked automatically with code checker There shall be no return statement in a void function.
6.8.6.4.c Checked automatically with code checker A function "return" expression shall be compatible with its explicitly defined type.
6.8.6.4.d Checked automatically with code checker Function return values that are error codes shall not be ignored.