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: Implementing OpenMP pragmas for the C front end


Steven Bosscher <s.bosscher@student.tudelft.nl> writes:

> Pragmas are registered in cpplib with a handler that is called from
> cpplib.  So the lexer and parser never see the pragmas. This makes it a
> bit difficult to have elaborate interaction between the parser and the
> pragma handlers.  There are additional callbacks for most pragmas from
> c-decl (the maybe_apply_{weak,renaming_pragma} functions) because the
> compiler may encounted symbols that are affected by those pragmas long
> after the pragma itself was handled.
>
> In OpenMP, the pragmas are more like grammar productions.  Certain
> pragmas can only be followed or by a compound statement, some other
> pragmas can only appear inside a compound.  Some constructs need
> information about scope and/or about how deep they're nested.
>
> In fact, the OpenMP specifications present the OpenMP pragmas as grammar
> extensions for C/C++!

Pragmas are callbacks only for historical reasons: It was easier to
implement them that way at the time.  With the C/C++ front ends moving
to recursive descent parsers, it would make perfect sense to put them
back in the token stream.  Perhaps we would transform

#pragma foo bar baz

into

__builtin_pragma foo bar baz;

and feed that to phase 7.

zw


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