This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: #pragma interface/implementation broken if --enable-mapped-location


On Fri, 24 Sep 2004, Zack Weinberg wrote:

> Suppose that cpplib, on encountering a #pragma, parsed the (namespace
> and) keyword to decide what it meant.  If the #pragma was unknown, it
> would then throw away the entire line.  If it was not unknown, it
> would inject a CPP_PRAGMA token at the beginning of the line *in place
> of* the token sequence # pragma [namespace] keyword.  The value of
> this token would be a function pointer for the appropriate #pragma
> handler.  I think that'd achieve both what you want and what I want,
> and would also avoid doing the handler lookup twice.

That should work (with the warning from -Wunknown-pragmas being given at 
the point an unknown pragma is thrown away).  For now yylex for C could 
handle that pragma token by calling the handler immediately (so the 
subsequent tokens never reach the parser).  With the possibility of then 
checking for particular pragmas and passing the token sequence on to the 
parser for those cases only.

I'd add that the CPP_PRAGMA token, though referred to as __pragma, 
shouldn't actually be spellable that way in source code; the only way to 
get one in the token stream should be #pragma / _Pragma (and perhaps the 
diagnostic messages complaining of such pragmas in bad places for the 
grammar should use the spelling "#pragma" rather than "PRAGMA").

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
  http://www.srcf.ucam.org/~jsm28/gcc/#c90status - status of C90 for GCC 4.0
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]