From: Pedro Alves <pedro@palves.net>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/6] Fix "ptype INTERNAL_FUNC" (PR gdb/30105)
Date: Wed, 15 Feb 2023 21:10:03 +0000 [thread overview]
Message-ID: <01c8ca93-d5e0-a12d-c331-eaadc0048835@palves.net> (raw)
In-Reply-To: <873578uv3e.fsf@tromey.com>
On 2023-02-14 3:26 p.m., Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:
>
> Pedro> That comment quoted above says that gcc -Wall will reveal any types
> Pedro> that haven't been handled, but that's not actually true, at least with
> Pedro> modern GCCs. You would need to enable -Wswitch-enum for that, which
> Pedro> we don't.
>
> We could do it for selected switches using a pragma, if we wanted.
Yeah, that is actually what I had done locally, to check which enums we
weren't handling, with the patch below.
> (What would be cool is an attribute to apply to the switch so we didn't
> have to wrap the whole thing.)
Yeah! I have the vague impression of once seeing that clang has something
like that, but I may be wrong.
>
> I tried enabling it globally but it has a lot of noise, and adding
> "default" all over defeats the purpose of the flag.
*nod*
From 715b0e7d83f02fe2e6356ea297d81dd6e3105858 Mon Sep 17 00:00:00 2001
From: Pedro Alves <pedro@palves.net>
Date: Thu, 9 Feb 2023 21:26:50 +0000
Subject: [PATCH] -Wswitch-enum
Change-Id: I09d8bab56abe241e21564812e910452a68752b1e
---
gdb/c-typeprint.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index dca96231117..3966961f149 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -372,6 +372,9 @@ c_type_print_varspec_prefix (struct type *type,
QUIT;
+DIAGNOSTIC_PUSH
+DIAGNOSTIC_ERROR ("-Wswitch-enum")
+
switch (type->code ())
{
case TYPE_CODE_PTR:
@@ -467,6 +470,8 @@ c_type_print_varspec_prefix (struct type *type,
error (_("type not handled in c_type_print_varspec_prefix()"));
break;
}
+
+DIAGNOSTIC_POP
}
/* Print out "const" and "volatile" attributes,
@@ -763,6 +768,9 @@ c_type_print_varspec_suffix (struct type *type,
QUIT;
+DIAGNOSTIC_PUSH
+DIAGNOSTIC_ERROR ("-Wswitch-enum")
+
switch (type->code ())
{
case TYPE_CODE_ARRAY:
@@ -848,6 +856,9 @@ c_type_print_varspec_suffix (struct type *type,
error (_("type not handled in c_type_print_varspec_suffix()"));
break;
}
+
+DIAGNOSTIC_POP
+
}
/* A helper for c_type_print_base that displays template
base-commit: b885aea1bb987435929b4298982ac6fc27f69403
prerequisite-patch-id: 8137bd248a83bbcb2cacfb0250eef1994eafaeac
prerequisite-patch-id: 78b3c4f199e7af4170c5fc713bd88fd4ac62dc36
--
2.36.0
next prev parent reply other threads:[~2023-02-15 21:10 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-10 23:35 [PATCH 0/6] Don't throw quit while handling inferior events Pedro Alves
2023-02-10 23:35 ` [PATCH 1/6] Fix "ptype INTERNAL_FUNC" (PR gdb/30105) Pedro Alves
2023-02-13 16:02 ` Andrew Burgess
2023-02-14 15:26 ` Tom Tromey
2023-02-15 21:10 ` Pedro Alves [this message]
2023-02-15 22:04 ` Tom Tromey
2023-02-10 23:36 ` [PATCH 2/6] Make "ptype INTERNAL_FUNCTION" in Ada print like other languages Pedro Alves
2023-02-13 16:02 ` Andrew Burgess
2023-02-14 15:30 ` Tom Tromey
2023-02-15 13:38 ` Pedro Alves
2023-02-15 15:13 ` Pedro Alves
2023-02-15 16:56 ` Tom Tromey
2023-02-15 21:04 ` [PATCH] Move TYPE_CODE_INTERNAL_FUNCTION type printing to common code (was: Re: [PATCH 2/6] Make "ptype INTERNAL_FUNCTION" in Ada print like other languages) Pedro Alves
2023-02-20 15:28 ` Andrew Burgess
2023-02-10 23:36 ` [PATCH 3/6] Add new "$_shell(CMD)" internal function Pedro Alves
2023-02-11 8:02 ` Eli Zaretskii
2023-02-13 15:11 ` Pedro Alves
2023-02-13 15:36 ` Eli Zaretskii
2023-02-13 16:47 ` [PATCH] gdb/manual: Move @findex entries (was: Re: [PATCH 3/6] Add new "$_shell(CMD)" internal function) Pedro Alves
2023-02-13 17:00 ` Eli Zaretskii
2023-02-13 17:27 ` [PATCH 3/6] Add new "$_shell(CMD)" internal function Pedro Alves
2023-02-13 18:41 ` Eli Zaretskii
2023-02-14 15:38 ` Tom Tromey
2023-02-10 23:36 ` [PATCH 4/6] Don't throw quit while handling inferior events Pedro Alves
2023-02-14 15:50 ` Tom Tromey
2023-02-10 23:36 ` [PATCH 5/6] GC get_active_ext_lang Pedro Alves
2023-02-14 15:39 ` Tom Tromey
2023-02-10 23:36 ` [PATCH 6/6] Don't throw quit while handling inferior events, part II Pedro Alves
2023-02-14 15:54 ` Tom Tromey
2023-02-15 21:16 ` Pedro Alves
2023-02-15 21:24 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=01c8ca93-d5e0-a12d-c331-eaadc0048835@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).