On Tue, Mar 25, 2014 at 03:35:29PM +0100, Richard Biener wrote:
> The following implements a special-case for LTO when doing %K
> formatting. LTO currently only keeps FUNCTION_DECL abstract
> origins (for BLOCKs satisfying inlined_function_outer_scope_p)
> which means the existing %K formatting usually bails out immediately.
> This severely complicates the search for warnings like
>
> /usr/include/bits/stdio2.h: In function ‘main’:
> /usr/include/bits/stdio2.h:293:2: warning: call to ‘__fread_chk_warn’
> declared with attribute warning: fread called with bigger size * nmemb
> than length of destination buffer
> return __fread_chk_warn (__ptr, __bos0 (__ptr), __size, __n, __stream);
> ^
>
> because you only have an outermost function context to work on
> and the inline stack can include functions from any translation
> unit with LTO. The following patch improves this to
>
> In function 'fread',
> inlined from 'main' at t.c:7:10:
> /usr/include/bits/stdio2.h:293:2: warning: call to '__fread_chk_warn'
> declared with attribute warning: fread called with bigger size * nmemb
> than length of destination buffer
> return __fread_chk_warn (__ptr, __bos0 (__ptr), __size, __n, __stream);
> ^
>
> which matches non-LTO behavior.
>
> Bootstrap/regtest pending on x86_64-unknown-linux-gnu, ok for trunk?
If it works, ok. I'd of course prefer if it preserved the abstract origins
properly, otherwise it can't emit proper debug info. But for now it is fine
I guess.
Jakub