From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76820 invoked by alias); 28 Nov 2017 17:37:35 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 76809 invoked by uid 89); 28 Nov 2017 17:37:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=BAYES_00,KB_WAM_FROM_NAME_SINGLEWORD,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=Hx-languages-length:1344 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Nov 2017 17:37:34 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D536F6A7F1; Tue, 28 Nov 2017 17:37:31 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-12.rdu2.redhat.com [10.10.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21B445C2F8; Tue, 28 Nov 2017 17:37:18 +0000 (UTC) Subject: Re: [C PATCH] Handle C SWITCH_EXPR in block_may_fallthru (PR sanitizer/81275) To: Jakub Jelinek , "Joseph S. Myers" , Marek Polacek , Richard Biener Cc: gcc-patches@gcc.gnu.org References: <20171128084928.GO2353@tucnak> From: Jeff Law Message-ID: <0a4d5461-2b49-6d1b-645a-8861554e64ad@redhat.com> Date: Tue, 28 Nov 2017 17:43:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171128084928.GO2353@tucnak> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-11/txt/msg02440.txt.bz2 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 > > 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