cpplib: expression parser messages

Zack Weinberg zack@wolery.cumb.org
Sun Apr 2 12:47:00 GMT 2000


On Sun, Apr 02, 2000 at 06:20:48PM +0900, Neil Booth wrote:
> This simple patch just improves some error messages by mentioning the
> operator the parser has stumbled on.  For example, the line
> 
> #if >= 4
> 
> used to produce the message
> 
> "operator has no left operand"
> 
> It now produces
> 
> "operator `>=' has no left operand"

The patch is okay for now.  In the future, please try to avoid static
variables if at all possible, because cpplib is supposed to be
somewhat reentrant.  The use in this patch is mostly harmless and the
new lexer will permit it to disappear quietly, so go ahead and commit
it.

> By the way, Zack, in testing this I noticed that
> 
> #if #
> 
> segfaults.  This happens because an assertion of zero length gets
> looked up in cpphash.c, and the hashing code assumes the length of the
> identifier it's passed is at least one.

It shouldn't be parsed as an assertion at all.  I'll fix this one.

zw


More information about the Gcc-patches mailing list