c/8927: Gcc give error for wrong line of C code.
Neil Booth
neil@daikokuya.co.uk
Sat Feb 15 23:57:00 GMT 2003
Steven Bosscher wrote:-
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8927
>
> The same problem happens for g++, so this is not a C bug.
>
> c_lex() and c-parse.in:_yylex() return the right line number for the
> token. But bison looks ahead a bit and that causes the line number to
> advance as well. This is also why saving the line number in the
> "primary" production doesn't help: Before we parse primary:IDENTIFIER,
> we've already advanced the line number.
>
> So my guess is that this is a cpplib bug: It should not advance the line
> number until the previous token is accepted. Dunno how to attack this
> bug.
CPP doesn't control the line number; it attaches line numbers to tokens,
and is therefore never wrong 8-)
Too bad the front end separates them. This whole area is currently
quite messy, and with bison unprofitably hard to fix. The C++ front
end should be able to do a near-perfect job now; though I can imagine
the current implementation of c-lex.c (which isn't appropriate to
RD parsers) getting in the way.
Neil.
More information about the Gcc-bugs
mailing list