This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C++: decl with initialization
Mark Mitchell <mark@codesourcery.com> writes:
| 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.
Thanks.
| 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.)
Indeed, I have been studying the code on mainline and I got the
impression that wasn't necessary any more.
Anyway, currently I believe it is not a real obstacle for the kind of
things I have to do.
Thanks,
-- Gaby