Go to the previous, next section.

Modifier Types

Modifier types are used to add various attributes to other types. Each attribute is represented by a different type operator:

TYPE_CONST
This modifier signals that the type is for constant values.

TYPE_VOLATILE
This is used for the types of variables whose contents may change at any time.

TYPE_CALL_BY_REF
This is used in the Fortran mode (see section Features for Compiling Fortran) to identify call-by-reference parameters.

TYPE_NULL
This modifier has no effect on the type but simply provides a place to attach annotations. This is needed for named types because copying them would create completely new types.

All of these modifier types use the modifier_type derived class. The base method returns a pointer to the type that is modified, and the set_base method changes that field. More than one modifier can be applied to the same type. The order of the modifiers does not matter, but no modifier should be used more than once with the same type (for example, a constant constant integer is illegal, but a constant pointer to a constant integer is OK).

The base type_node class includes several methods to deal with modifiers. The is_const, is_volatile, and is_call_by_ref methods check for the corresponding modifiers on a type. The unqual method skips over any modifier types and returns the unqualified type. This is used frequently when checking for particular kinds of types. Finally, the find_modifier method checks if a type is modified by a particular modifier type operator. If so, it returns a pointer to that modifier type; otherwise it returns NULL.

Go to the previous, next section.