On 07/31/2018 12:50 PM, Martin Sebor wrote:
> Attached is a much scaled-down patch that only adds a note
> to the -Warray-bounds warnings mentioning the declaration
> to which the out-of-bounds index or offset applies.
> 
> Printing the inlining context needs a bit more work but
> this small improvement can be made independently of it.
> 
> On 07/23/2018 05:49 PM, Martin Sebor wrote:
>> (David, I'm hoping your your help here.  Please see the end.)
>>
>> While looking into a recent -Warray-bounds instance in Glibc
>> involving inlining of large functions it became apparent that
>> GCC could do a better job of pinpointing the source of
>> the problem.
>>
>> The attached patch makes a few adjustments to both
>> the pretty printer infrastructure and to VRP to make this
>> possible.  The diagnostic pretty printer already has directives
>> to print the inlining context for both tree and gcall* arguments,
>> so most of the changes just adjust things to be able to pass in
>> gimple* argument instead.
>>
>> The only slightly interesting change is to print the declaration
>> to which the out-of-bounds array refers if one is known.
>>
>> Tested on x86_64-linux with one regression.
>>
>> The regression is in the gcc.dg/Warray-bounds.c test: the column
>> numbers of the warnings are off.  Adding the %G specifier to
>> the array bounds warnings in VRP has the unexpected effect of
>> expanding the extent of the underling. For instance, for a test
>> case like this:
>>
>>   int a[10];
>>
>>   void f (void)
>>   {
>>     a[-1] = 0;
>>   }
>>
>> from the expected:
>>
>>    a[-1] = 0;
>>    ~^~~~
>>
>> to this:
>>
>>   a[-1] = 0;
>>    ~~~~~~^~~
>>
>> David, do you have any idea how to avoid this?
>>
>> Martin
> 
> 
> gcc-86650.diff
> 
> 
> PR tree-optimization/86650 - -Warray-bounds missing inlining context
> 
> gcc/ChangeLog:
> 
>       PR tree-optimization/86650
>       * tree-vrp.c (vrp_prop::check_array_ref): Print an inform message.
>       (vrp_prop::check_mem_ref): Same.
> 
> gcc/testsuite/ChangeLog:
> 
>       PR tree-optimization/86650
>       * gcc.dg/Warray-bounds-33.c: New test.
OK.
jeff

Reply via email to