[diagnostics-branch] use precise locations in C front-end

Joseph S. Myers joseph@codesourcery.com
Mon Dec 15 00:59:00 GMT 2008

On Fri, 12 Dec 2008, Tom Tromey wrote:

> Note that Joseph's 4.5 patches mean that the C FE will no longer fold
> so aggressively.  So, this sort of oddity will be more rare -- it will
> be restricted to errors issued after the FE.

And where it does still fold partial expressions other than as part of the 
final folding of a full expression, this is often because such folding is 
presently required for good diagnostics (e.g. -Wsign-compare not warning 
when the compiler can prove that the particular signed operand in question 
is never negative; I added a few more tests for folding-dependent cases of 
this to the testsuite after finding cases that only arose in bootstrap on 
some platforms and weren't covered in the testsuite, but there are 
probably many more such cases that matter).

The folding in these cases can still be incrementally delayed through at 
least two possible changes: either make the diagnostics code smarter to 
handle the important cases using the unfolded expressions, or delay the 
diagnostics to be run from c_fully_fold with explicit nodes representing 
e.g. "implicit sign conversion in a comparison".  Some people want much of 
the folding for optimization to be run even later than c_fully_fold (on 
language-independent IR after the front end has finished) with only much 
more limited folding run from the front end, which would dictate making 
the diagnostics smarter, although delaying lowering of implicit 
conversions may also be a good idea and in general lots of small 
"optimizations" in C front-end code should move to the lowering stage or 
be made language-independent or be removed if no longer needed.

Joseph S. Myers

More information about the Gcc-patches mailing list