Skip to content

Evaluate Implied Enum Constants

Robert L. Bocchino Jr. edited this page Apr 18, 2024 · 3 revisions

This algorithm traverses the a source model and computes the implied values of enumeration constants that have no explicit value.

Input

  1. A list tul of translation units.

  2. An analysis data structure a representing the results of analysis so far.

Output

  1. The analysis a with an updated value map, if the evaluation succeeds; otherwise an error.

Procedure

For each enum definition d:

  1. Check that d has all explicit constants C = e or all implied constants C. If not, throw an error.

  2. If d has implied constants, then add the implicit values 0, 1, 2, …​ to the value map.