Re: Which compiler pass prints a warning?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/18/2016 12:23 PM, Martin Sebor wrote:
On 09/17/2016 11:08 AM, Florian Weimer wrote:
For warnings issued by the optimizers, is there a way to get the name
of the pass which runs when the warning is generated?

I don't know of an easy or reliable way other than to grep the source
code for the text of warning (or its substrings when it's split across
multiple lines).
Correct. There's currently no way to know if a warning comes from the FE or any particular pass in the pipeline. I believe everyone greps for the warning in the sources to figure that out.



Short of that, I think it might be possible to come
close by looking at where in the output of -fdump-tree-all=/dev/stderr
the diagnostic appears and determining the pass from the context.
E.g., by

  gcc -O2 -S -Wall -fdump-tree-all=/dev/stdout z.c 2>&1 | less

and then searching the output for the warning and figuring out from
the contents of the dump around it what pass might have issued it.
Unfortunately, the dumps don't contain the name of their pass (I've
wished they did for other reasons) so this exercise isn't completely
straightforward either.
It'd probably work, but it isn't terribly user friendly :-)

PS I think it would be useful to be able to more easily pinpoint
the source line responsible for emitting a diagnostic.  Others will
have a better idea of how feasible it might be to do but it seems
that having calls to error_at, warning_at, and others pass the
__FILE__ and __LINE__ of their caller to the diagnostic machinery
should make it possible to include this information in the text of
each diagnostic in response to some new option.
Seems like it may be worth investigating. There are certainly times when knowing what pass spit out an error/warning would be helpful.

jeff




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux