[PATCH][RFC] Add a subset of -Warray-bounds warnings to C/C++ front ends
Mark Mitchell
mark@codesourcery.com
Tue Apr 8 19:42:00 GMT 2008
Richard Guenther wrote:
>> Thoughts? Okay for trunk?
>
> I think it is a good thing to move these to the frontends.
Me too! The code all looks good. However, I do think this should be
factored into a function in c_common.
Also:
+ if (min_index && TREE_CODE (min_index) == INTEGER_CST
+ && tree_int_cst_lt (idx, min_index))
+ {
+ warning (OPT_Warray_bounds,
+ "array subscript is below array bounds");
could do with a better error message. In C/C++, the min_index is (I
believe) always zero. I think you're right to have written the test in
terms of min_index (future-proofing!), but I think we should special
case the message. If the idx is negative and the min_index is zero, say:
"array subscript is negative"
That's more obvious to the average user.
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
More information about the Gcc-patches
mailing list