This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c/8927: Gcc give error for wrong line of C code.
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: Steven Bosscher <s dot bosscher at student dot tudelft dot nl>
- Cc: gcc-gnats at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, gp at qnx dot com,nobody at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org,Wolfgang Bangerth <bangerth at ticam dot utexas dot edu>
- Date: Sat, 15 Feb 2003 23:57:37 +0000
- Subject: Re: c/8927: Gcc give error for wrong line of C code.
- References: <1045346207.736.66.camel@steven>
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.