Main Content

Suppress generation of default cases for Stateflow switch statements if unreachable

Whether to generate default cases for switch-case statements for Stateflow charts

Model Configuration Pane: Code Generation / Code Style

Description

Specify whether to generate default cases for switch-case statements in the code for Stateflow® charts. This optimization works on a per-model basis. It applies to the code generated for a state that has multiple substates. For a list of the state functions in the generated code, see Inline State Functions in Generated Code.

Settings

on (default) | off

Default: on

On

Do not generate the default case when it is unreachable. This setting enables better code coverage because every branch in the generated code is falsifiable.

Off

Generate a default case whether or not it is reachable. This setting supports MISRA C® compliance and provides a backup in case of RAM corruption.

Examples

expand all

Compare the generated code when you set Suppress generation of default cases for Stateflow switch statements if unreachable to different values.

Here is generated code that generated using the default Suppress generation of default cases for Stateflow switch statements if unreachable value off. When the state has a nontrivial entry function, the following default case appears in the generated code for the during function::

default:
 entry_internal();
 break;

With Suppress generation of default cases for Stateflow switch statements if unreachable set to on, the generated code does not contain the default case.

Recommended Settings

ApplicationSetting
DebuggingNoimpact
TraceabilityOn
EfficiencyOn (execution, ROM), No impact (RAM)
Safety precaution

No recommendation

Programmatic Use

Parameter: SuppressUnreachableDefaultCases
Type: character vector
Value: 'on' | 'off'
Default: 'on'

Version History

Introduced in R2011b