Next:Statement Sequences, Previous:Basic Statements, Up:Statements [Contents][Index]
Block scopes and the variables they declare in GENERIC areexpressed using theBIND_EXPR code, which in previousversions of GCC was primarily used for the C statement-expressionextension.
Variables in a block are collected intoBIND_EXPR_VARS indeclaration order through theirTREE_CHAIN field. Any runtimeinitialization is moved out ofDECL_INITIAL and into astatement in the controlled block. When gimplifying from C or C++,this initialization replaces theDECL_STMT. These variableswill never require cleanups. The scope of these variables is just thebody
Variable-length arrays (VLAs) complicate this process, as their sizeoften refers to variables initialized earlier in the block and theirinitialization involves an explicit stack allocation. To handle this,we add an indirection and replace them with a pointer to stack spaceallocated by means ofalloca. In most cases, we also arrangefor this space to be reclaimed when the enclosingBIND_EXPR isexited, the exception to this being when there is an explicit call toalloca in the source code, in which case the stack is leftdepressed on exit of theBIND_EXPR.
A C++ program will usually contain moreBIND_EXPRs thanthere are syntactic blocks in the source code, since several C++constructs have implicit scopes associated with them. On theother hand, although the C++ front end uses pseudo-scopes tohandle cleanups for objects with destructors, these don’ttranslate into the GIMPLE form; multiple declarations at the samelevel use the sameBIND_EXPR.
Next:Statement Sequences, Previous:Basic Statements, Up:Statements [Contents][Index]