From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 75008 invoked by alias); 27 Nov 2017 12:49:47 -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 74999 invoked by uid 89); 27 Nov 2017 12:49:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:2254 X-HELO: mail-yw0-f169.google.com Received: from mail-yw0-f169.google.com (HELO mail-yw0-f169.google.com) (209.85.161.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Nov 2017 12:49:45 +0000 Received: by mail-yw0-f169.google.com with SMTP id q37so11763615ywa.12 for ; Mon, 27 Nov 2017 04:49:45 -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=t8uTGDtX1dPDBlMitjW9kR7PL3F27aIWix/mf+ORygA=; b=r/BxPvN7m8Vkg28/Luy7RvEOJoeviYPY8tJ6mnjHdiTzrGho7vQTMLrWN/aJQ4JJLw v1hk6T31Gtl8v31kPIeBZLU1UCIyi1HdNfIFZoM5UjfI2Pbe7DIyFPvtQBe8+J8ONXFp 92JnbOh2lQH9hQxYT++aHOGekERFSk/iL6AjQ27H9tZdu/TgduDYvfKdYz9dmlQeXaqb C91BLwvQJEpYONNyEHw7irxaIkKa0cK5kFLmMhMycpgE2IRgN4/tKBUyVGQ8XOSy16K3 xyXpNwNqoaHA9DEaPXuO7B/DALU51bp/5/DItuV9LFZyyKHdqsEaI/8hPd5FUHXAyWTP 28Bw== X-Gm-Message-State: AJaThX7U/y7MoTL3o8PFqXyNnoUAMdrZRQPdx8oEWwuCIhXX7yKWs0aH kf1fCJB2To14cMgqHZAmiZY= X-Google-Smtp-Source: AGs4zMYlKYRX7OUnTO+u79ohILF9+zN5vhP6nyLc49xYfTGAO6Toa4i7ChmHRfb6sdmM/2S5fVRrBw== X-Received: by 10.129.79.136 with SMTP id d130mr23882966ywb.258.1511786983600; Mon, 27 Nov 2017 04:49:43 -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 i207sm12024189ywe.38.2017.11.27.04.49.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Nov 2017 04:49:43 -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> <20171125090122.GH14653@tucnak> <20171126002256.GJ14653@tucnak> From: Nathan Sidwell Message-ID: <553dc61a-6963-2d41-d55d-9b3fab8bd6f0@acm.org> Date: Mon, 27 Nov 2017 13:39: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: <20171126002256.GJ14653@tucnak> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2017-11/txt/msg02297.txt.bz2 On 11/25/2017 07:22 PM, Jakub Jelinek wrote: > On Sat, Nov 25, 2017 at 10:01:22AM +0100, Jakub Jelinek wrote: >> Actually, thinking about it some more, maybe it would be more efficient >> to gather this information during construction of the SWITCH_STMT in some >> new flag on the tree, so cxx_block_may_fallthru would just: > > Here it is implemented, bootstrapped/regtested on x86_64-linux and > i686-linux, ok for trunk? nice. > --- gcc/cp/cp-tree.h.jj 2017-11-17 08:40:32.000000000 +0100 > +++ gcc/cp/cp-tree.h 2017-11-25 21:25:48.277897180 +0100 > +/* Set if the body of a switch stmt contains a default: case label > + and does not contain any break; stmts, thus if SWITCH_STMT_BODY > + is not empty and doesn't fallthru, then the whole SWITCH_STMT > + can't fallthru either. */ > +#define SWITCH_STMT_CANNOT_FALLTHRU_P(NODE) \ > + TREE_LANG_FLAG_0 (SWITCH_STMT_CHECK (NODE)) The macro name isn't quite right. As the comment says, it's not sufficient that this flag is set for the switch to not fall through -- the switch body must be non-empty (which I presume it cannot be as there must be a default label), and it cannot fall through in its own right. The semantics of this flag are more like SWITCH_STMT_COVERS_ALL_CASES, perhaps something of that ilk would be a clearer name? nathan -- Nathan Sidwell