]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Convert c_string_type to an enum flags type
authorSimon Marchi <simon.marchi@ericsson.com>
Tue, 17 Nov 2015 13:31:29 +0000 (13:31 +0000)
committerPedro Alves <palves@redhat.com>
Tue, 17 Nov 2015 13:31:29 +0000 (13:31 +0000)
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.

gdb/ChangeLog
gdb/c-exp.y
gdb/c-lang.c
gdb/c-lang.h

index 1c6cc7dd4f9c95cd876cb7db2db1b6a2fc6fa6f8..a5a752cfd614a79d6eff0886ff575ab316d8aa4b 100644 (file)
@@ -1,3 +1,19 @@
+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.
+
 2015-11-17  Pedro Alves  <palves@redhat.com>
 
        * btrace.h: Include common/enum-flags.h.
index f2de0aed4348af7f34cea96465760f8d5330fe7d..912775623f0d9ae0a98fba20dd0808cea0588923 100644 (file)
@@ -864,7 +864,7 @@ string_exp:
 exp    :       string_exp
                        {
                          int i;
-                         enum c_string_type type = C_STRING;
+                         c_string_type type = C_STRING;
 
                          for (i = 0; i < $1.len; ++i)
                            {
@@ -878,7 +878,7 @@ exp :       string_exp
                                  if (type != C_STRING
                                      && type != $1.tokens[i].type)
                                    error (_("Undefined string concatenation."));
-                                 type = (enum c_string_type) $1.tokens[i].type;
+                                 type = (enum c_string_type_values) $1.tokens[i].type;
                                  break;
                                default:
                                  /* internal error */
@@ -2164,7 +2164,7 @@ parse_string_or_char (const char *tokptr, const char **outptr,
                      struct typed_stoken *value, int *host_chars)
 {
   int quote;
-  enum c_string_type type;
+  c_string_type type;
   int is_objc = 0;
 
   /* Build the gdb internal form of the input string in tempbuf.  Note
index 384783cb167a71d387c8000602388789fe7e3fde..2646b05c2bdfcdc2ae6baf5277ab51595a8f0a53 100644 (file)
@@ -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:
index 5e30481d751025db2441e7c88fbb1b5990d8573c..b921cf4921a548f490908358cefb9c8750b67d76 100644 (file)
@@ -29,12 +29,13 @@ struct parser_state;
 #include "value.h"
 #include "macroexp.h"
 #include "parser-defs.h"
+#include "common/enum-flags.h"
 
 
 /* The various kinds of C string and character.  Note that these
    values are chosen so that they may be or'd together in certain
    ways.  */
-enum c_string_type
+enum c_string_type_values
   {
     /* An ordinary string: "value".  */
     C_STRING = 0,
@@ -56,6 +57,8 @@ enum c_string_type
     C_CHAR_32 = 7
   };
 
+DEF_ENUM_FLAGS_TYPE (enum c_string_type_values, c_string_type);
+
 /* Defined in c-exp.y.  */
 
 extern int c_parse (struct parser_state *);