[2/7] gdb: convert INT_* macros into an enum_flags
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
Commit Message
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(-)
@@ -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;
@@ -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);
@@ -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