Query module AV Rule 145

name
Irregular enum initialization
description
In an enumerator list, the = construct should not be used to explicitly initialize members other than the first, unless all items are explicitly initialized. An exception is the pattern to use the last element of an enumerator list to get the number of possible values.
kind
problem
problem.severity
recommendation
precision
high
id
cpp/irregular-enum-init
tags
reliability readability language-features external/jsf

Imports

cpp

Provides classes and predicates for working with C/C++/ObjC/ObjC++ code.

Predicates

enumThatHasConstantWithImplicitValue
hasInitializer
hasNonReferenceInitializer

Does this have an initializer that is not just a ref to another constant in the same enum?

hasReferenceInitializer