diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index dc52ee8b003..d68985ca277 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -809,16 +809,15 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy)) unsigned int option_index = find_opt (option_string + 1, lang_mask); if (option_index == OPT_SPECIAL_unknown) { - option_proposer op; - const char *hint = op.suggest_option (option_string + 1); - if (hint) - warning_at (loc, OPT_Wpragmas, - "unknown option after %<#pragma GCC diagnostic%> kind;" - " did you mean %<-%s%>?", hint); - else - warning_at (loc, OPT_Wpragmas, - "unknown option after %<#pragma GCC diagnostic%> kind"); - + auto_diagnostic_group d; + if (warning_at (loc, OPT_Wpragmas, + "unknown option after %<#pragma GCC diagnostic%> kind")) + { + option_proposer op; + const char *hint = op.suggest_option (option_string + 1); + if (hint) + inform (loc, "did you mean %<-%s%>?", hint); + } return; } else if (!(cl_options[option_index].flags & CL_WARNING)) diff --git a/gcc/testsuite/gcc.dg/pragma-diag-6.c b/gcc/testsuite/gcc.dg/pragma-diag-6.c index 0dca1dc1ef4..f2df88d245b 100644 --- a/gcc/testsuite/gcc.dg/pragma-diag-6.c +++ b/gcc/testsuite/gcc.dg/pragma-diag-6.c @@ -2,7 +2,10 @@ #pragma GCC diagnostic error "-Wnoexcept" /* { dg-warning "is valid for C../ObjC.. but not for C" } */ #pragma GCC diagnostic error "-fstrict-aliasing" /* { dg-warning "not an option that controls warnings" } */ #pragma GCC diagnostic error "-Werror" /* { dg-warning "not an option that controls warnings" } */ -#pragma GCC diagnostic error "-Wvla2" /* { dg-warning "unknown option after '#pragma GCC diagnostic' kind; did you mean '-Wvla'" } */ -#pragma GCC diagnostic error "-Walla" /* { dg-warning "unknown option after '#pragma GCC diagnostic' kind; did you mean '-Wall'" } */ -#pragma GCC diagnostic warning "-Walla" /* { dg-warning "unknown option after '#pragma GCC diagnostic' kind; did you mean '-Wall'" } */ +#pragma GCC diagnostic error "-Wvla2" /* { dg-warning "unknown option after '#pragma GCC diagnostic' kind" } */ +/* { dg-message "did you mean '-Wvla'" "" { target *-*-* } .-1 } */ +#pragma GCC diagnostic error "-Walla" /* { dg-warning "unknown option after '#pragma GCC diagnostic' kind" } */ +/* { dg-message "did you mean '-Wall'" "" { target *-*-* } .-1 } */ +#pragma GCC diagnostic warning "-Walla" /* { dg-warning "unknown option after '#pragma GCC diagnostic' kind" } */ +/* { dg-message "did you mean '-Wall'" "" { target *-*-* } .-1 } */ int i;