gccint: Blocks

1 
1 11.7.2 Blocks
1 -------------
1 
1 Block scopes and the variables they declare in GENERIC are expressed
1 using the 'BIND_EXPR' code, which in previous versions of GCC was
1 primarily used for the C statement-expression extension.
1 
1  Variables in a block are collected into 'BIND_EXPR_VARS' in declaration
1 order through their 'TREE_CHAIN' field.  Any runtime initialization is
1 moved out of 'DECL_INITIAL' and into a statement in the controlled
1 block.  When gimplifying from C or C++, this initialization replaces the
1 'DECL_STMT'.  These variables will never require cleanups.  The scope of
1 these variables is just the body
1 
1  Variable-length arrays (VLAs) complicate this process, as their size
1 often refers to variables initialized earlier in the block and their
1 initialization involves an explicit stack allocation.  To handle this,
1 we add an indirection and replace them with a pointer to stack space
1 allocated by means of 'alloca'.  In most cases, we also arrange for this
1 space to be reclaimed when the enclosing 'BIND_EXPR' is exited, the
1 exception to this being when there is an explicit call to 'alloca' in
1 the source code, in which case the stack is left depressed on exit of
1 the 'BIND_EXPR'.
1 
1  A C++ program will usually contain more 'BIND_EXPR's than there are
1 syntactic blocks in the source code, since several C++ constructs have
1 implicit scopes associated with them.  On the other hand, although the
1 C++ front end uses pseudo-scopes to handle cleanups for objects with
1 destructors, these don't translate into the GIMPLE form; multiple
1 declarations at the same level use the same 'BIND_EXPR'.
1