Am 2022-11-23 um 21:11 schrieb Richard Biener via Gcc-patches: > On Wed, Nov 23, 2022 at 3:08 PM Iskander Shakirzyanov via Gcc-patches > wrote: >> >> Hi! >> Sorry for the initially missing description. >> The following patch changes the definition of -Warray-bounds to an Alias to -Warray-bounds=1. This is necessary for the correct use of -Werror=array-bounds=X, for more information see bug report 107787 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107787) >> As I understand, this happens because -Warray-bounds and -Warray-bounds= are declared as 2 different options in common.opt, so when diagnostic_classify_diagnostic() (opts-common.cc:1880) is called, DK_ERROR is set for the -Warray-bounds= option, but in diagnostic_report_diagnostic() (diagnostic.cc:1446) through warning_at() passes opt_index of -Warray-bounds, so information about DK_ERROR is lost. > > How did you test the patch? If you bootstrapped it and ran the > testsuite then it's OK. Hi, I'm pretty sure the testsuite will have regressions, as I have a very similar patch lying around that needs these testsuite changes. I also added some modified tests that check that -Werror=array-bounds=X works as expected (which it didn't before). This also shows nicely why I don't like warnings with levels, what if I want -Werror=array-bounds=2 + -Warray-bounds=1? The reason (besides lack of time) I didn't submit that patch yet, is that I wanted to check if the tool to process common.opt can be changed to detect warnings with duplicated warning variables. Because I think at least -Wuse-after-free= and Wattributes= have the same problem. BTW, is the duplicated warning description "Warn if an array is accessed out of bounds." needed or not with Alias()? There are examples either way in common.opt. I've attached my patch, feel free to integrate the testsuite changes. Franz