Re: [C++ PATCH] Fix constexpr switch handling (PR c++/77467, take 2)

2016-09-28 Thread Jason Merrill
OK, thanks. Jason

[C++ PATCH] Fix constexpr switch handling (PR c++/77467, take 2)

2016-09-20 Thread Jakub Jelinek
On Mon, Sep 19, 2016 at 02:34:17PM -0400, Jason Merrill wrote: > > For STATEMENT_LIST that is called by cxx_eval_constant_expression, > > for BIND_EXPR if we are lucky enough that BIND_EXPR_BODY is a STATEMENT_LIST > > too (otherwise I assume even my patch doesn't fix it, it would need to > > verif

Re: [C++ PATCH] Fix constexpr switch handling (PR c++/77467)

2016-09-19 Thread Jason Merrill
On Fri, Sep 16, 2016 at 4:44 PM, Jakub Jelinek wrote: > On Fri, Sep 16, 2016 at 03:51:11PM -0400, Jason Merrill wrote: >> On Mon, Sep 5, 2016 at 1:11 PM, Jakub Jelinek wrote: >> > + /* If body is a statement other than STATEMENT_LIST or BIND_EXPR, >> > + it should be skipped. E.g. switch (a

Re: [C++ PATCH] Fix constexpr switch handling (PR c++/77467)

2016-09-16 Thread Jakub Jelinek
On Fri, Sep 16, 2016 at 03:51:11PM -0400, Jason Merrill wrote: > On Mon, Sep 5, 2016 at 1:11 PM, Jakub Jelinek wrote: > > + /* If body is a statement other than STATEMENT_LIST or BIND_EXPR, > > + it should be skipped. E.g. switch (a) b = a; */ > > + if (TREE_CODE (body) == STATEMENT_LIST >

Re: [C++ PATCH] Fix constexpr switch handling (PR c++/77467)

2016-09-16 Thread Jason Merrill
On Mon, Sep 5, 2016 at 1:11 PM, Jakub Jelinek wrote: > + /* If body is a statement other than STATEMENT_LIST or BIND_EXPR, > + it should be skipped. E.g. switch (a) b = a; */ > + if (TREE_CODE (body) == STATEMENT_LIST > + || TREE_CODE (body) == BIND_EXPR) I'm nervous about this optim

[C++ PATCH] Fix constexpr switch handling (PR c++/77467)

2016-09-05 Thread Jakub Jelinek
Hi! cxx_eval_switch_expr assumes that SWITCH_EXPR's body is always a STATEMENT_LIST, but that doesn't have to be the case. As the testcase shows, if there are any variable declarations in the switch body, it can be also a BIND_EXPR, which cxx_eval_constant_expression handles properly, and as bar i