This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 1/2] gcc symbol database
- From: Yunfeng ZHANG <zyf dot zeroos at gmail dot com>
- To: Dodji Seketeli <dodji at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, "Joseph S. Myers" <joseph at codesourcery dot com>, Dave Korn <dave dot korn dot cygwin at googlemail dot com>, Tom Tromey <tromey at redhat dot com>
- Date: Tue, 17 Jul 2012 15:14:41 +0800
- Subject: Re: [PATCH 1/2] gcc symbol database
- References: <CA+dUcj3G+MhuQSOQVo5H=wK7R8PQ0MSOdX_s0+xM_ZvXXJkCJQ@mail.gmail.com> <m3aa0j18gf.fsf@redhat.com> <CA+dUcj2p5DbZkJbzBcD955EGv6H9YGM1cQ38Bd9i8daUs4SgPA@mail.gmail.com> <CA+dUcj151pDt82wbG1OrwgUp=24TiPM2MkQkDiUdYBcatbhZGw@mail.gmail.com> <87mx332614.fsf@seketeli.org> <CA+dUcj3jpmRAZWyDDiAKN1RuN2AgLWwQwfbETBkRw1LWfYeSOg@mail.gmail.com> <m3obnfwwn5.fsf@redhat.com>
Please allow me to resend former sample:
#define Z(a) a
#define Y Z
#define X(p) p + Y
X(1)(2);
The flow is:
1) `X' -- leader macro token by macro_start_expand.
2) `(', `1', `)' -- macro tokens, by cb_lex_token.
3) macro_end_arg.
4) `1', `+' -- macro replacement tokens, by symdb_cpp_token.
5) `(', `2', `)' -- macro tokens, by cb_lex_token.
6) macro_end_arg.
7) `2' -- macro replacement tokens, by symdb_cpp_token.
8) macro_end_expand.
The thing I emphasized here is cb_lex_token is set by macro_start_expand
intern -- it isn't valid anytime. So
buff = funlike_invocation_p (pfile, node, &pragma_buff,
...
if (buff == NULL)
{
...
}
if macro_start_expand is moved to the clause block `buff != NULL', it's too
later to set cb_lex_token because funlike_invocation_p has read some macro
tokens.
Of course I can remove macro_end_arg totally, because from the sample, it's the
fact that macro tokens aren't always before any macro replacement tokens. But
macro_end_expand must be prepared to deal with cancel case.
BTW, currently it isn't necessary to my plugin to collect macro tokens, so if
gcc doesn't support collect macro token event, macro_start_expand and
macro_end_expand can be moved into enter_macro_context and _cpp_pop_context
individually.
Yunfeng