From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70461 invoked by alias); 27 Nov 2017 12:43:29 -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 70450 invoked by uid 89); 27 Nov 2017 12:43:29 -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,FREEMAIL_FROM,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=H*r:2254 X-HELO: mail-qt0-f172.google.com Received: from mail-qt0-f172.google.com (HELO mail-qt0-f172.google.com) (209.85.216.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Nov 2017 12:43:27 +0000 Received: by mail-qt0-f172.google.com with SMTP id i40so27577206qti.8 for ; Mon, 27 Nov 2017 04:43:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5GKyOorENhKyIAxVyLY0vY12m59pqRVgzOoLjrQ//UQ=; b=AVcIi1S/3VnHc1Sy4pbdTzqWoJAPZR3sacGHNzSWuMOvMKCiQJ9Qc/4apDaz6q6IzM fIUiw9kKEifcRFvVgkSrLBksag02553yxAwpfF2PAcKHCBwl/GnJxnnu2jhsN7j5B/4E nzA5TRCePaBN8BabhNMR3UYCMu3e4AHzZzEvjnXD3d2FXq4ztSh0d/Gp2OwH3JCNFC0p OdHl5MZgXhWWOYxte3R90HZQDb2QPrblGgxVO68rylBECbYAV5s89rT7h+nmn1yd1VhU dVu9Yk9opF6319X6erwVI18lQDI7Jj4M9xyfp4HH3ikM7aqOuD1IyrmLELiA5nKIEPX4 VNYA== X-Gm-Message-State: AJaThX4pg/coU1EjatROSNjfCIISLL8uSSAtBtQP2z/lI/C2e5eKfrgd oVV69zBGkAULWJ0FojGL0FU= X-Google-Smtp-Source: AGs4zMasUK1z2oQq0hctZEErMSLVBn/9cV0ZDc/PxepH1OATf3FbgY1DKuTi98oTJCgZj1LbOB/g3w== X-Received: by 10.200.3.85 with SMTP id w21mr34866828qtg.148.1511786606093; Mon, 27 Nov 2017 04:43:26 -0800 (PST) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::3:38a4]) by smtp.googlemail.com with ESMTPSA id k1sm16981700qtf.11.2017.11.27.04.43.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Nov 2017 04:43:25 -0800 (PST) Subject: Re: [C++ PATCH] Avoid -Wreturn-type warnings if a switch has default label, no breaks inside of it, but is followed by a break (PR sanitizer/81275) To: Jakub Jelinek , Jason Merrill Cc: gcc-patches@gcc.gnu.org References: <20171124215953.GE14653@tucnak> From: Nathan Sidwell Message-ID: Date: Mon, 27 Nov 2017 12:44: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: <20171124215953.GE14653@tucnak> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2017-11/txt/msg02293.txt.bz2 On 11/24/2017 04:59 PM, Jakub Jelinek wrote: > Hi! > > The testcase below has a useless break; that causes a bogus -Wreturn-type > warning. The C++ FE already has code to avoid adding a BREAK_STMT > after a return or similar sequence that is known not to return. > The following patch extends block_may_fallthrough to also return false > for SWITCH_STMTs that can't fall through. > > Those are ones with non-empty body where the whole body can't fallthrough, > additionally they need to have a default: case label (or cover the whole > range of values, but that is not what this patch can compute, that would > be too big duplication of the gimplification processing) and no BREAK_STMT. > > For the default: case label we need to look in all SWITCH_BODY children > except for nested SWITCH_STMTs, for BREAK_STMTs also not in > {FOR,DO,WHILE}_BODY. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2017-11-24 Jakub Jelinek > > PR sanitizer/81275 > * cp-objcp-common.c (struct find_default_and_break_s): New type. > (find_default_and_break): New function. > (cxx_block_may_fallthru): Return false for SWITCH_STMT which > contains no BREAK_STMTs and contains a default: CASE_LABEL_EXPR. > > * g++.dg/warn/pr81275.C: New test. ok -- Nathan Sidwell