This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][stage1] Add option suggestion for -Werror=foo and corresponding pragma.
On 3/5/19 3:47 PM, David Malcolm wrote:
> On Tue, 2019-03-05 at 15:14 +0100, Martin Liška wrote:
>> Hi.
>>
>> The patch extends option suggestion for both -Werror and
>> corresponding
>> pragram.
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression
>> tests.
>>
>> Ready to be installed after stage1 opens?
>> Thanks,
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2019-03-05 Martin Liska <mliska@suse.cz>
>>
>> * opts.c (enable_warning_as_error): Provide hints
>> for unknown options.
>>
>> gcc/c-family/ChangeLog:
>>
>> 2019-03-05 Martin Liska <mliska@suse.cz>
>>
>> * c-pragma.c (handle_pragma_diagnostic): Provide hints
>> for unknown options.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2019-03-05 Martin Liska <mliska@suse.cz>
>>
>> * gcc.dg/Werror-13.c: Add new tests for it.
>> * gcc.dg/pragma-diag-6.c: Likewise.
>> ---
>> gcc/c-family/c-pragma.c | 13 +++++++++++--
>> gcc/opts.c | 17 ++++++++++++++---
>> gcc/testsuite/gcc.dg/Werror-13.c | 12 +++++++-----
>> gcc/testsuite/gcc.dg/pragma-diag-6.c | 3 +++
>> 4 files changed, 35 insertions(+), 10 deletions(-)
>
>> diff --git a/gcc/testsuite/gcc.dg/Werror-13.c b/gcc/testsuite/gcc.dg/Werror-13.c
>> index e8aa99261f8..9f221c303ba 100644
>> --- a/gcc/testsuite/gcc.dg/Werror-13.c
>> +++ b/gcc/testsuite/gcc.dg/Werror-13.c
>> @@ -1,8 +1,10 @@
>> /* { dg-do compile } */
>> -/* { dg-options "-Werror=error -Werror=p, -Werror=l, -Werror=fatal-errors" } */
>> -/* { dg-error "-Wp, is not an option that controls warnings" "" { target *-*-* } 0 } */
>> -/* { dg-error "-Wl, is not an option that controls warnings" "" { target *-*-* } 0 } */
>> -/* { dg-error "-Werror is not an option that controls warnings" "" { target *-*-* } 0 } */
>> -/* { dg-error "-Wfatal-errors is not an option that controls warnings" "" { target *-*-* } 0 } */
>> +/* { dg-options "-Werror=error -Werror=p, -Werror=l, -Werror=fatal-errors -Werror=vla2 -Wno-error=misleading-indentation2" } */
>> +/* { dg-error ".-Wp,. is not an option that controls warnings" "" { target *-*-* } 0 } */
>> +/* { dg-error ".-Wl,. is not an option that controls warnings" "" { target *-*-* } 0 } */
>> +/* { dg-error ".-Werror. is not an option that controls warnings" "" { target *-*-* } 0 } */
>> +/* { dg-error ".-Wfatal-errors. is not an option that controls warnings" "" { target *-*-* } 0 } */
>> +/* { dg-error ".-Werror=vla2.: no option .-Wvla2.; did you mean .-Wvla." "" { target *-*-* } 0 } */
>> +/* { dg-error ".-Wno-error=misleading-indentation2.: no option .-Wmisleading-indentation2.; did you mean .-Wmisleading-indentation." "" { target *-*-* } 0 } */
>
> A minor nit here: I don't like the approach of using "." for quotes in
> dg- directives, as this will match any character. The testsuite runs
> in LANG=C, so the quotes appear as the "'" character, so it's safe to
> just use the "'" character in these directives. It's also more
> precise: we want the test to fail if it isn't a quote.
>
> So e.g. the last line might be better as:
>
> /* { dg-error "'-Wno-error=misleading-indentation2': no option '-Wmisleading-indentation2'; did you mean '-Wmisleading-indentation'" "" { target *-*-* } 0 } */
>
> which I think is also much more readable.
Agree with that! I'm going to adjust that in this patch and
mainly in the quoting patch that I've been working on.
Martin
>
> [But let's not go back and change this in existing testcases; I just
> thought it worth mentioning because you fixed the quoting here]
>
> Dave
>