variable_decl Production

Definition

variable_decl : identifier : typename ;
              | identifier : typename = exp ; 

Purpose

A variable_decl creates a variable in the current context. This variable may be initialized, or it may simply be created.

Semantics

If there is an initializer, its type must be compatible with the type given by typename. Additionally, at the global scope, the exp must be free of all side-effects.

Variables declared with the extern specifier must not have an initializer. Variables declared with the const specifier must have initializers unless they are in a signature.

A variable declaration may only coexist with a declaration of the same name only if the typenames of both match, and one is declared with the extern specifier.

Exactly one function_def may coexist with exactly one uninitialized variable_decl, of a type compatible with typename, plus the const type qualifier.