From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 2/7] gdb: convert INT_* macros into an enum_flags
Date: Thu, 1 Oct 2026 16:30:00 -0400 [thread overview]
Message-ID: <20261001203105.1379971-3-simon.marchi@efficios.com> (raw)
In-Reply-To: <20261001203105.1379971-1-simon.marchi@efficios.com>
Same as the previous patch, but for the INT_* macros passed to
cpname_state::d_int_type. Add an INT_NONE enumerator, since a raw enum
value can't be assigned 0:
CXX cp-name-parser-gen.o
gdb/cp-name-parser.y: In function ‘int cpname_yyparse(cp_name_parser::cpname_state*)’:
gdb/cp-name-parser.y:544:67: error: invalid conversion from ‘int’ to ‘cp_name_parser::int_flag’ [-fpermissive]
544 | { $$ = 0; }
| ^
| |
| int
Change-Id: Ia4e8b576adfd5b3baa3fb4c4beda2517d1d87449
---
gdb/cp-name-parser.c | 4 ++--
gdb/cp-name-parser.h | 27 ++++++++++++++++-----------
gdb/cp-name-parser.y | 19 +++++++++++--------
3 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/gdb/cp-name-parser.c b/gdb/cp-name-parser.c
index 569d102213c8..6615efd6abb1 100644
--- a/gdb/cp-name-parser.c
+++ b/gdb/cp-name-parser.c
@@ -147,7 +147,7 @@ cpname_state::d_qualify (struct demangle_component *lhs,
/* Return a builtin type corresponding to FLAGS. */
struct demangle_component *
-cpname_state::d_int_type (int flags)
+cpname_state::d_int_type (int_flags flags)
{
const char *name;
@@ -162,7 +162,7 @@ cpname_state::d_int_type (int flags)
case INT_UNSIGNED | INT_CHAR:
name = "unsigned char";
break;
- case 0:
+ case INT_NONE:
case INT_SIGNED:
name = "int";
break;
diff --git a/gdb/cp-name-parser.h b/gdb/cp-name-parser.h
index 7585379f5be2..083631f20a67 100644
--- a/gdb/cp-name-parser.h
+++ b/gdb/cp-name-parser.h
@@ -26,16 +26,6 @@
union cp_name_parser_YYSTYPE;
struct demangle_parse_info;
-/* Flags passed to cpname_state::d_int_type. */
-
-#define INT_CHAR (1 << 0)
-#define INT_SHORT (1 << 1)
-#define INT_LONG (1 << 2)
-#define INT_LLONG (1 << 3)
-
-#define INT_SIGNED (1 << 4)
-#define INT_UNSIGNED (1 << 5)
-
#define d_left(dc) (dc)->u.s_binary.left
#define d_right(dc) (dc)->u.s_binary.right
@@ -53,6 +43,21 @@ enum qual_flag
DEF_ENUM_FLAGS_TYPE (enum qual_flag, qual_flags);
+/* Integer type specifiers, passed to cpname_state::d_int_type. */
+
+enum int_flag
+{
+ INT_NONE = 0,
+ INT_CHAR = 1 << 0,
+ INT_SHORT = 1 << 1,
+ INT_LONG = 1 << 2,
+ INT_LLONG = 1 << 3,
+ INT_SIGNED = 1 << 4,
+ INT_UNSIGNED = 1 << 5,
+};
+
+DEF_ENUM_FLAGS_TYPE (enum int_flag, int_flags);
+
/* State of an ongoing parse. */
struct cpname_state
@@ -109,7 +114,7 @@ struct cpname_state
struct demangle_component *d_qualify (struct demangle_component *lhs,
qual_flags qualifiers, int is_method);
- struct demangle_component *d_int_type (int flags);
+ struct demangle_component *d_int_type (int_flags flags);
struct demangle_component *d_unary (const char *name,
struct demangle_component *lhs);
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index b41ca6b30a20..4b4be60f4fba 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -61,6 +61,7 @@
} abstract;
int lval;
cp_name_parser::qual_flag qual;
+ cp_name_parser::int_flag int_type;
const char *opname;
}
@@ -87,7 +88,7 @@
%type <qual> qualifier qualifiers qualifiers_opt
-%type <lval> int_part int_seq
+%type <int_type> int_part int_seq
%token <comp> INT
%token <comp> FLOAT
@@ -540,22 +541,24 @@ qualifiers : qualifier
invalid output for them - an error would be better. */
int_part : INT_KEYWORD
- { $$ = 0; }
+ { $$ = cp_name_parser::INT_NONE; }
| SIGNED_KEYWORD
- { $$ = INT_SIGNED; }
+ { $$ = cp_name_parser::INT_SIGNED; }
| UNSIGNED
- { $$ = INT_UNSIGNED; }
+ { $$ = cp_name_parser::INT_UNSIGNED; }
| CHAR
- { $$ = INT_CHAR; }
+ { $$ = cp_name_parser::INT_CHAR; }
| LONG
- { $$ = INT_LONG; }
+ { $$ = cp_name_parser::INT_LONG; }
| SHORT
- { $$ = INT_SHORT; }
+ { $$ = cp_name_parser::INT_SHORT; }
;
int_seq : int_part
| int_seq int_part
- { $$ = $1 | $2; if ($1 & $2 & INT_LONG) $$ = $1 | INT_LLONG; }
+ { $$ = $1 | $2;
+ if ($1 & $2 & cp_name_parser::INT_LONG)
+ $$ = $1 | cp_name_parser::INT_LLONG; }
;
builtin_type : int_seq
--
2.55.0
next prev parent reply other threads:[~2026-10-01 20:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 20:29 [PATCH 0/7] Leftovers from parsers cleanup Simon Marchi
2026-10-01 20:29 ` [PATCH 1/7] gdb: convert QUAL_* macros into an enum_flags Simon Marchi
2026-10-01 20:30 ` Simon Marchi [this message]
2026-10-01 20:30 ` [PATCH 3/7] gdb: convert d_left and d_right macros into functions Simon Marchi
2026-10-01 20:30 ` [PATCH 4/7] gdb: replace cp-name-parser.c macros with lambdas Simon Marchi
2026-10-01 20:30 ` [PATCH 5/7] gdb: use std::string for f-exp-parser.c's tempbuf Simon Marchi
2026-10-01 20:30 ` [PATCH 6/7] gdb: remove qsort kludge from ada-exp-parser.y Simon Marchi
2026-10-01 20:30 ` [PATCH 7/7] gdb: make COMPLETE_CHAR a constexpr Simon Marchi
2026-10-14 12:54 ` [PATCH 0/7] Leftovers from parsers cleanup Tom Tromey
2026-10-14 13:13 ` Simon Marchi
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=20261001203105.1379971-3-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
/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