[PATCH] Type-safe wrapper for enum flags

Pedro Alves palves@redhat.com
Fri Oct 30 17:39:00 GMT 2015


On 10/30/2015 02:15 PM, Simon Marchi wrote:

> Could we also make c_string_type an enum flags type?  Like so?  There are
> some ugly casts remaining in the branch, like
> 
>   str_type = (enum c_string_type) (str_type & ~C_CHAR);

Good idea, indeed looks like we can.

> --- a/gdb/c-lang.h
> +++ b/gdb/c-lang.h
> @@ -34,7 +34,7 @@ struct parser_state;
>  /* 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 +56,8 @@ enum c_string_type
>      C_CHAR_32 = 7
>    };
> 
> +DEF_ENUM_FLAGS_TYPE (enum c_string_type_values, c_string_type);

Looks like c-lang.h should include common/enum_flags.h.

Otherwise LGTM.

I'd like to collect at least one Ack on the enum flags patch
before pushing it.

Thanks,
Pedro Alves



More information about the Gdb-patches mailing list