* [PATCH] Avoid more -Wformat-diag warnings [PR103758]
@ 2022-01-05 23:45 Marek Polacek
2022-01-06 0:41 ` Joseph Myers
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2022-01-05 23:45 UTC (permalink / raw)
To: GCC Patches
Let's use "%<x>, %<y>, or %<z>" rather than "[x|y|z]" as in the rest of
our codebase.
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/11?
PR c++/103758
gcc/c-family/ChangeLog:
* c-pragma.c (handle_pragma_scalar_storage_order): Use %< %> in
diagnostic messages.
(handle_pragma_diagnostic): Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/sso-6.c: Update dg-warning.
---
gcc/c-family/c-pragma.c | 16 ++++++++++------
gcc/testsuite/gcc.dg/sso-6.c | 4 ++--
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c
index ecf4457aacd..8dde5b841b2 100644
--- a/gcc/c-family/c-pragma.c
+++ b/gcc/c-family/c-pragma.c
@@ -441,7 +441,8 @@ handle_pragma_scalar_storage_order (cpp_reader *ARG_UNUSED(dummy))
token = pragma_lex (&x);
if (token != CPP_NAME)
- GCC_BAD ("missing [big-endian|little-endian|default] after %<#pragma scalar_storage_order%>");
+ GCC_BAD ("missing %<big-endian%>, %<little-endian%>, or %<default%> after "
+ "%<#pragma scalar_storage_order%>");
kind_string = IDENTIFIER_POINTER (x);
if (strcmp (kind_string, "default") == 0)
global_sso = default_sso;
@@ -450,7 +451,8 @@ handle_pragma_scalar_storage_order (cpp_reader *ARG_UNUSED(dummy))
else if (strcmp (kind_string, "little") == 0)
global_sso = SSO_LITTLE_ENDIAN;
else
- GCC_BAD ("expected [big-endian|little-endian|default] after %<#pragma scalar_storage_order%>");
+ GCC_BAD ("expected %<big-endian%>, %<little-endian%>, or %<default%> after "
+ "%<#pragma scalar_storage_order%>");
}
/* GCC supports two #pragma directives for renaming the external
@@ -771,8 +773,9 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy))
if (token != CPP_NAME)
{
warning_at (loc, OPT_Wpragmas,
- "missing [error|warning|ignored|push|pop|ignored_attributes]"
- " after %<#pragma GCC diagnostic%>");
+ "missing %<error%>, %<warning%>, %<ignored%>, %<push%>, "
+ "%<pop%>, or %<ignored_attributes%> after "
+ "%<#pragma GCC diagnostic%>");
return;
}
@@ -830,8 +833,9 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy))
else
{
warning_at (loc, OPT_Wpragmas,
- "expected [error|warning|ignored|push|pop|ignored_attributes]"
- " after %<#pragma GCC diagnostic%>");
+ "expected %<error%>, %<warning%>, %<ignored%>, %<push%>, "
+ "%<pop%>, %<ignored_attributes%> after "
+ "%<#pragma GCC diagnostic%>");
return;
}
diff --git a/gcc/testsuite/gcc.dg/sso-6.c b/gcc/testsuite/gcc.dg/sso-6.c
index e955fa93686..559253293b5 100644
--- a/gcc/testsuite/gcc.dg/sso-6.c
+++ b/gcc/testsuite/gcc.dg/sso-6.c
@@ -3,7 +3,7 @@
/* { dg-do run } */
/* { dg-require-effective-target int32plus } */
-#pragma scalar_storage_order /* { dg-warning "missing .big-endian.little-endian.default." } */
+#pragma scalar_storage_order /* { dg-warning "missing .big-endian., .little-endian., or .default." } */
#pragma scalar_storage_order big-endian
@@ -36,7 +36,7 @@ struct S5
int i;
};
-#pragma scalar_storage_order other /* { dg-warning "expected .big-endian.little-endian.default." } */
+#pragma scalar_storage_order other /* { dg-warning "expected .big-endian., .little-endian., or .default." } */
struct S1 my_s1 = { 0x12345678 };
struct S2 my_s2 = { 0x12345678 };
base-commit: 4ec62dbafe0cb3b79cc635dfb964ef6a7ccc2d40
--
2.33.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Avoid more -Wformat-diag warnings [PR103758]
2022-01-05 23:45 [PATCH] Avoid more -Wformat-diag warnings [PR103758] Marek Polacek
@ 2022-01-06 0:41 ` Joseph Myers
0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2022-01-06 0:41 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
On Wed, 5 Jan 2022, Marek Polacek via Gcc-patches wrote:
> Let's use "%<x>, %<y>, or %<z>" rather than "[x|y|z]" as in the rest of
> our codebase.
>
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/11?
OK.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-06 0:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 23:45 [PATCH] Avoid more -Wformat-diag warnings [PR103758] Marek Polacek
2022-01-06 0:41 ` Joseph Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).