This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++: decl with initialization
On 29 Jun 2003 16:27:53 -0700, Mark Mitchell <mark@codesourcery.com> wrote:
> On Sun, 2003-06-29 at 14:18, Gabriel Dos Reis wrote:
>>
>> I have been studying the code in cp/decl.c:start_decl that handles
>> initial declarations. When a decl is initialized, the DECL_INITIAL is
>> set to error_mark_node instead of the true real initializer. Why and
>> what are the benefits doing that instead of using the true initializer?
>
> The true initializer isn't available when we create the initial DECL
> node -- after all the declaration has to be in scope during the
> processing of the initializer so that things like "void *p = &p;"
> works. There is code that wants to know whether or not the declaration
> is initialized when the declaration is created.
Also, a variable with a dynamic initializer, such as a constructor call,
gets a DECL_INITIAL of error_mark_node.
Jason