This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Implementing OpenMP pragmas for the C front end
- From: Zack Weinberg <zack at codesourcery dot com>
- To: Steven Bosscher <s dot bosscher at student dot tudelft dot nl>
- Cc: gcc at gcc dot gnu dot org, OpenMP for GCC project <gomp-discuss at nongnu dot org>
- Date: Tue, 11 Feb 2003 08:37:38 -0800
- Subject: Re: Implementing OpenMP pragmas for the C front end
- References: <1044655909.800.139.camel@steven>
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