Simple CPP failure (snapshot 20000313)
Zack Weinberg
zack@wolery.cumb.org
Mon Mar 27 21:07:00 GMT 2000
On Thu, Mar 23, 2000 at 11:42:32PM +0900, Neil Booth wrote:
> Jonathan Larmour wrote:-
>
> > CPP does not deal with the following file correctly:
> >
> > -=-=-=-=-=-=-=- cut here -=-=-=-=-=-=-=-
> > #define X (16*(40) + 192)
> > #define Y 2048
> >
> > #if Y < X
> > #undef Y
> > #define Y X
> > #endif
> >
> > Y
> > -=-=-=-=-=-=-=- cut here -=-=-=-=-=-=-=-
>
> Thanks for your bug report. This is being caused by the parser in
> cppexp.c deciding that the '+' is unary. It decides this because its
> test for a unary +/- is (effectively) "if the previous token is an
> operator it's unary, otherwise it's binary".
Right.
> The problem with this is that ')' is treated as an operator, however
> it is not really an operator in it's own right, but more just a
> syntactic indicator of the range of the previous '('.
>
> The following patch fixes the problem, and bootstraps. Whether it is
> the "correct" patch I'm not so sure.
It may be the correct patch, but it seems to me that (40) should have
been reduced to 40 as soon as we saw the right paren, and therefore the
HAVE_VALUE check should suffice. Could you try to figure out why it
isn't being reduced?
> Incidentally, one minor problem with the current parser is it allows
> too many unary operators, e.g. the following line parses without
> warning or error:
>
> #if 1 + + + 1
Bleagh. That's probably a standards violation. A patch would be welcome :)
zw
More information about the Gcc-bugs
mailing list