This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -traditional comment elimination (yuk...)
Zack Weinberg wrote:-
> Yes, I reread it, and I get it now. But I don't see how this follows:
>
> > No, the problems will appear on any line, but *only when we combine
> > cpplib and the front end*. We get away with it until then because the
> > front end does its own lexing pass.
>
> because, in open text
>
> foo &/**/& bar
>
> should be being pasted into <foo> <&&> <bar> already, in
Yes, that case is not a problem. The following is:-
dou/**/ble
will (correctly) produce <dou><ble> in the preprocessor, but the
frontend will not see a single <double> token when linked up. Trying
to do it in one pass is possible with ugly hacks, but then avoiding
your
#def/**/ine
example is yet another ugly hack, because it really isn't a #define.
Two passes is cleanest and easiest to get both cases right, and the
countless corner cases we almost certainly haven't thought of (and
that's what scares me the most).
> To get the variant effect of comments on directive lines (other than
> #define), we could cause comments to be equivalent to whitespace in
> directives, even when -traditional (which is what a K+R preprocessor
> did).
I think two passes will get everything right with minimal changes, and
minimal changes to a correctly-functioning non-traditional lexer is
the way I'd like to keep it (in mouth-watering anticipation of the
wonderful day when we finally do drop -traditional).
Neil.