summaryrefslogtreecommitdiff
path: root/gdb/c-lang.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2015-11-17 13:31:29 +0000
committerPedro Alves <palves@redhat.com>2015-11-17 13:31:29 +0000
commit0c801b966379f7826fdd793b26ae879c2edf78d1 (patch)
tree7fbfb4292f6c342d0e0902a9d744c338355fa100 /gdb/c-lang.c
parent8d297bbf604c8318ffc72d5a7b3db654409c5ed9 (diff)
Convert c_string_type to an enum flags type
c_string_type contains values meant to be OR'ed together (even though some bits are mutually exclusive), so it makes sense to make it an enum flags type. gdb/ChangeLog: 2015-11-17 Simon Marchi <simon.marchi@ericsson.com> * c-exp.y (exp): Adjust, change enum c_string_type to c_string_type. (parse_string_or_char): Likewise. * c-lang.c (charset_for_string_type): Likewise. (classify_type): Likewise. (c_printchar): Likewise. (c_printstr): Likewise. (evaluate_subexp_c): Likewise. And change cast to enum c_string_type_values. * c-lang.h: Include "common/enum_flags.h". (enum c_string_type): Rename to... (enum c_string_type_values): ...this. (c_string_type): Define new enum flags type.
Diffstat (limited to 'gdb/c-lang.c')
-rw-r--r--gdb/c-lang.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 384783cb16..2646b05c2b 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -41,8 +41,7 @@ extern void _initialize_c_language (void);
character set name. */
static const char *
-charset_for_string_type (enum c_string_type str_type,
- struct gdbarch *gdbarch)
+charset_for_string_type (c_string_type str_type, struct gdbarch *gdbarch)
{
switch (str_type & ~C_CHAR)
{
@@ -72,11 +71,11 @@ charset_for_string_type (enum c_string_type str_type,
characters of this type in target BYTE_ORDER to the host character
set. */
-static enum c_string_type
+static c_string_type
classify_type (struct type *elttype, struct gdbarch *gdbarch,
const char **encoding)
{
- enum c_string_type result;
+ c_string_type result;
/* We loop because ELTTYPE may be a typedef, and we want to
successively peel each typedef until we reach a type we
@@ -155,7 +154,7 @@ c_emit_char (int c, struct type *type,
void
c_printchar (int c, struct type *type, struct ui_file *stream)
{
- enum c_string_type str_type;
+ c_string_type str_type;
str_type = classify_type (type, get_type_arch (type), NULL);
switch (str_type)
@@ -191,7 +190,7 @@ c_printstr (struct ui_file *stream, struct type *type,
const char *user_encoding, int force_ellipses,
const struct value_print_options *options)
{
- enum c_string_type str_type;
+ c_string_type str_type;
const char *type_encoding;
const char *encoding;
@@ -577,7 +576,7 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
struct obstack output;
struct cleanup *cleanup;
struct value *result;
- enum c_string_type dest_type;
+ c_string_type dest_type;
const char *dest_charset;
int satisfy_expected = 0;
@@ -589,8 +588,8 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
++*pos;
limit = *pos + BYTES_TO_EXP_ELEM (oplen + 1);
- dest_type
- = (enum c_string_type) longest_to_int (exp->elts[*pos].longconst);
+ dest_type = ((enum c_string_type_values)
+ longest_to_int (exp->elts[*pos].longconst));
switch (dest_type & ~C_CHAR)
{
case C_STRING: