On 11/28/2017 01:49 AM, Jakub Jelinek wrote:
> Hi!
>
> This is the C version of the switch block_may_fallthru handling.
> Unlike C++ SWITCH_STMT, break; is represented in SWITCH_EXPR by a goto
> to a label emitted after the SWITCH_EXPR, so either block_may_fallthru
> finds such label (but then doesn't find the SWITCH_EXPR), or it
> finds SWITCH_EXPR, in which case if the body doesn't fall through (e.g.
> ends with a return stmt), then it may fall through only if it doesn't
> cover all the cases.
>
> This patch adds a bit that signals that, and computes whether all cases
> are covered (either if default: is present, or by walking the splay tree).
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2017-11-28 Jakub Jelinek <ja...@redhat.com>
>
> PR sanitizer/81275
> * tree.c (block_may_fallthru): Return false if SWITCH_ALL_CASES_P
> is set on SWITCH_EXPR and !block_may_fallthru (SWITCH_BODY ()).
> c/
> * c-typeck.c (c_finish_case): Set SWITCH_ALL_CASES_P if
> c_switch_covers_all_cases_p returns true.
> c-family/
> * c-common.c (c_switch_covers_all_cases_p_1,
> c_switch_covers_all_cases_p): New functions.
> * c-common.h (c_switch_covers_all_cases_p): Declare.
> testsuite/
> * c-c++-common/tsan/pr81275.c: New test.
OK.
jeff