Additional statements

Code Coverage for C

Terminal Statements

A C statement is terminal if it transfers program control out of sequence (RETURN, GOTO, BREAK, CONTINUE), or stops the execution (EXIT).

By extension, a decision statement (IF or SWITCH) is terminal if all branches are terminal; that is if the non-empty THEN ... ELSE, CASE, and DEFAULT blocks all contain terminal statements. An IF statement without an ELSE and a SWITCH statement without a DEFAULT are never terminal, because their empty blocks necessarily continue program control in sequence.

Potentially Terminal Statements

The following decision statements are potentially terminal if they contain at least one statement that transfers program control out of their sequence (RETURN, GOTO, BREAK, CONTINUE), or that terminates the execution (EXIT):

  • IF without an ELSE

  • SWITCH

  • FOR

  • WHILE or DO ... WHILE

Non-coverable Statements in C

Some C statements are considered non-coverable if they follow a terminal instruction, a CONTINUE, or a BREAK, and are not a GOTO label. Code Coverage detects non-coverable statements during instrumentation and produces a warning message that specifies the source file and line location of each non-coverable statement.

Note User functions whose purpose is to terminate execution unconditionally are not evaluated. Furthermore, Code Coverage does not statically analyze exit conditions for loops to check whether they are infinite. As a result, FOR ... WHILE and DO ... WHILE loops are always assumed to be non-terminal, able to resume program control in sequence.

Related Topics

Selecting coverage types | Code Coverage settings