Re: [C/C++ PATCH] Handle enum bit-fields for -Wswitch (PR c/61405, PR c/53874)

2014-09-23 Thread Jason Merrill
OK. Jason

Re: [C/C++ PATCH] Handle enum bit-fields for -Wswitch (PR c/61405, PR c/53874)

2014-09-23 Thread Marek Polacek
On Fri, Sep 19, 2014 at 03:39:39PM -0400, Jason Merrill wrote: > On 09/19/2014 09:29 AM, Marek Polacek wrote: > >But we also started to warn on > >CPP_KEYWORD and two others: "case value not in enumerated type". > >Fixed by moving CPP_KEYWORD, CPP_TEMPLATE_ID, and CPP_NESTED_NAME_SPECIFIER > >into

Re: [C/C++ PATCH] Handle enum bit-fields for -Wswitch (PR c/61405, PR c/53874)

2014-09-19 Thread Jason Merrill
On 09/19/2014 09:29 AM, Marek Polacek wrote: But we also started to warn on CPP_KEYWORD and two others: "case value not in enumerated type". Fixed by moving CPP_KEYWORD, CPP_TEMPLATE_ID, and CPP_NESTED_NAME_SPECIFIER into enum cpp_ttype. Not sure if this is going to hurt something else. Wait,

Re: [C/C++ PATCH] Handle enum bit-fields for -Wswitch (PR c/61405, PR c/53874)

2014-09-19 Thread Marek Polacek
On Fri, Sep 19, 2014 at 11:19:14AM -0400, Jason Merrill wrote: > On 09/19/2014 09:29 AM, Marek Polacek wrote: > >- orig_type = TREE_TYPE (cond); > >+ /* Handle enum bit-fields. */ > >+ tree field; > >+ if (TREE_CODE (cond) == COMPONENT_REF > >+ && (field = TREE_OPERAND (co

Re: [C/C++ PATCH] Handle enum bit-fields for -Wswitch (PR c/61405, PR c/53874)

2014-09-19 Thread Jason Merrill
On 09/19/2014 09:29 AM, Marek Polacek wrote: - orig_type = TREE_TYPE (cond); + /* Handle enum bit-fields. */ + tree field; + if (TREE_CODE (cond) == COMPONENT_REF + && (field = TREE_OPERAND (cond, 1)) + && DECL_BIT_FIELD_TYPE (field) + && TREE_CODE (DE

Re: [C/C++ PATCH] Handle enum bit-fields for -Wswitch (PR c/61405, PR c/53874)

2014-09-19 Thread Jakub Jelinek
On Fri, Sep 19, 2014 at 03:29:44PM +0200, Marek Polacek wrote: > Jakub, does the asan.c change look ok? > --- gcc/gcc/asan.c > +++ gcc/gcc/asan.c > @@ -2024,6 +2024,8 @@ maybe_instrument_call (gimple_stmt_iterator *iter) > case BUILT_IN_TRAP: > /* Don't instrument these. */

[C/C++ PATCH] Handle enum bit-fields for -Wswitch (PR c/61405, PR c/53874)

2014-09-19 Thread Marek Polacek
This patch makes -Wswitch{,-enum} work even with enum bit-fields (we got several bugreports about that). The problem is that enum e:2; has an integral type with precision 2, and c_do_switch_warnings doesn't like that: 6195 /* From here on, we only care about about enumerated types. */ 6196 if