From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53344 invoked by alias); 16 Apr 2015 17:27:44 -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 53298 invoked by uid 89); 16 Apr 2015 17:27:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: resqmta-po-01v.sys.comcast.net Received: from resqmta-po-01v.sys.comcast.net (HELO resqmta-po-01v.sys.comcast.net) (96.114.154.160) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 16 Apr 2015 17:27:42 +0000 Received: from resomta-po-05v.sys.comcast.net ([96.114.154.229]) by resqmta-po-01v.sys.comcast.net with comcast id GhSz1q0084xDoy801hTgy7; Thu, 16 Apr 2015 17:27:40 +0000 Received: from [IPv6:2001:558:6045:a4:40c6:7199:cd03:b02d] ([IPv6:2001:558:6045:a4:40c6:7199:cd03:b02d]) by resomta-po-05v.sys.comcast.net with comcast id GhTe1q0052ztT3H01hTfl8; Thu, 16 Apr 2015 17:27:39 +0000 Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: [RFC stage 1] Proposed new warning: -Wmisleading-indentation From: Mike Stump In-Reply-To: <1429196485.32584.46.camel@surprise> Date: Thu, 16 Apr 2015 17:27:00 -0000 Cc: "gcc-patches@gcc.gnu.org" Content-Transfer-Encoding: quoted-printable Message-Id: <6A97A5CB-3000-4030-9E5C-BE55AE79F164@comcast.net> References: <1429196485.32584.46.camel@surprise> To: David Malcolm X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00828.txt.bz2 On Apr 16, 2015, at 8:01 AM, David Malcolm wrote: > Attached is a work-in-progress patch for a new > -Wmisleading-indentation > warning I've been experimenting with, for GCC 6. Seems like a nice idea in general. Does it also handle: if (cone); stmt; ? Would be good to add that to the test suite, as that is another hard to = spot common error that should be caught. I do think that it is reasonable to warn for things like: stmt; stmt; one of those two lines is likely misindented, though, maybe you want to sta= rt with the high payback things first. > An issue here is how to determine (i), or if it's OK to default to 8 Yes, 8 is the proper value to default it to. > and have a command-line option (param?) to override it? (though what abou= t, > say, each header file?) I=92ll abstain from this. The purist in me says no option for other than 8= , life goes on. 20 years ago, someone was confused over hard v soft tabbin= g and what exactly the editor key TAB does. That confusion is over, the 8 = people have won. Catering to other than 8 gives the impression that the pe= ople that lost still have a chance at winning. :-) > Thoughts on this, and on the patch? Would be nice to have a stricter version that warns about all wildly incons= istently or wrongly indented lines. { stmt; stmt; // must be same as above } { stmt; // must be indented at least 1 } if (cond) stmt; // must be indented at least 1