This is the mail archive of the gcc-patches@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: [gomp] Parser for OpenMP directives


On Tue, 29 Mar 2005, Zack Weinberg wrote:

> "Joseph S. Myers" <joseph@codesourcery.com> writes:
> 
> > I concur with Zack's view that cpplib should end up expanding all
> > non-ignored pragmas as a token sequence (with or without macro
> > expansion) which is then parsed by the parser however it likes.
> > This would start with a special token for #pragma, end with a
> > special token for the end of a #pragma (I prefer such a special
> > token to ending with an ordinary ';' token) and inbetween have the
> > tokens of the pragma.
> 
> Why the special ending token?  I'm not aware of any situation where we
> need ';' in the middle of a pragma's arguments.

';' could occur where an expression in the pragma's arguments is a 
statement expression (or, within standard C, an expression defining a 
structure type in a cast or sizeof); in such cases a special token avoids 
syntactically invalid code parsing as if some of the subsequent code were 
on the #pragma line.  More generally, parser error recovery should always 
be able to stop at an end-pragma token to stop syntax errors in a #pragma 
from affecting the rest of the file, whereas it might or might not stop at 
a ';' token; for example, trying to find a closing ')' for an expression 
might not stop at ';' but would stop at the end of a #pragma.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery 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]