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 Thu, 23 Sep 2004, Zack Weinberg wrote:

> Alternatively, I wanted originally to defer pragmas not by
> encapsulating the un-tokenized line in a string, but by injecting a
> keyword (__pragma) at the beginning of the line, a semicolon at the
> end, and tokenizing normally (but with macro expansion disabled).
> Matt persuaded me that was hard to implement, but maybe it should be
> revisited.

That would also probably be convenient for OpenMP pragma implementation 
for C (where the pragmas can contain expressions that need to go through 
the parser as usual).  But for most target pragmas attempting to hook them 
in the grammar like that would seem an excess complication; the grammar 
would effectively just gather up a sequence of arbitrary tokens again to 
pass to the target pragma handler.  (Bearing in mind the general 
desirability that target pragmas share a single implementation for C and 
C++.)

I don't care for having three separate paths for pragma handling 
(immediate on lexing, deferred as a pragma token, deferred as a sequence 
of tokens), which suggests making C use the pragma token (but handle it 
immediately on parsing) and then allow for some pragmas - depending on the 
individual pragma - to become token sequences instead.

I wonder if also the check for unrecognized pragmas should be made before 
the pragma becomes any sort of token, on the basis that the C and C++ 
standards explicitly say that unknown pragmas are ignored (and so should 
be permitted anywhere in the source file, not just in reasonable places).  
That would seem cleaner than documenting that all pragmas are recognized 
in order to give errors if they occur in an inconvenient place.

-- 
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]