[PATCH] issue -Walloca even when alloca is a system header macro [PR94004]

Martin Sebor msebor@gmail.com
Wed Mar 4 21:07:00 GMT 2020


A 2017 change that propagated call location to GIMPLE statements
had the unexpected (though not incorrect) effect of setting
the location on calls to __builtin_alloca.  When such calls are
the result of the expansion of the alloca macro defined in
a system header like <alloca.h>, the change prevents -Walloca and 
-Walloca-larger-than
warnings from being issued unless -Wsystem-headers is also used,
effectively defeating the point of the first two warnings in most
code.

The attached patch changes -Walloca to use the location of the point
of the macro expansion rather than that of its definition, restoring
the intended behavior.

In addition, to make the warnings (mainly -Wvla) in inlined code
easier to debug, the patch also arranges for the warnings to include
their inlining context.

Tested on x86_64-linux.

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-94004.diff
Type: text/x-patch
Size: 6967 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20200304/3511839c/attachment.bin>


More information about the Gcc-patches mailing list