This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++: decl with initialization
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: gcc at gcc dot gnu dot org, jason at redhat dot com
- Date: 29 Jun 2003 16:27:53 -0700
- Subject: Re: C++: decl with initialization
- References: <m3he68vayn.fsf@uniton.integrable-solutions.net>
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.
With the new parser, it's probably possible to get rid of the trick you
mention above; I suspect that the context required could simply be
maintained in local variables in the parser. (That didn't used to be
possible because in the YACC parser there's no such thing as "local
variables", except for using empty productions as places to store
values.)
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com