From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46164 invoked by alias); 18 Jun 2015 16:39:26 -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 45978 invoked by uid 89); 18 Jun 2015 16:39:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 18 Jun 2015 16:39:24 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 836303798A9; Thu, 18 Jun 2015 16:39:23 +0000 (UTC) Received: from [10.3.232.67] (vpn-232-67.phx2.redhat.com [10.3.232.67]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5IGdMCU008881; Thu, 18 Jun 2015 12:39:23 -0400 Message-ID: <1434645111.14663.146.camel@surprise> Subject: Re: [PATCH 3/3] Improve -Wmissing-indentation heuristics From: David Malcolm To: Patrick Palka Cc: gcc-patches@gcc.gnu.org Date: Thu, 18 Jun 2015 16:46:00 -0000 In-Reply-To: <1433871067-30661-3-git-send-email-patrick@parcs.ath.cx> References: <1433871067-30661-1-git-send-email-patrick@parcs.ath.cx> <1433871067-30661-3-git-send-email-patrick@parcs.ath.cx> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg01287.txt.bz2 On Tue, 2015-06-09 at 13:31 -0400, Patrick Palka wrote: > This patch improves the heuristics of the warning in a number of ways. > The improvements are hopefully adequately documented in the code > comments. > > The additions to the test case also highlight the improvements. > > I tested an earlier version of this patch on more than a dozen C code > bases. I only found one class of bogus warnings yet emitted, in the > libpng and bdwgc projects. These projects have a coding style which > indents code inside #ifdefs as if this code was guarded by an if(), e.g. > > if (foo != 0) > x = 10; > else // GUARD > y = 100; // BODY > > #ifdef BAR > blah (); // NEXT > #endif We have detect_preprocessor_logic which suppresses warnings when there's preprocessor logic between BODY_EXPLOC and NEXT_STMT_EXPLOC, for cases like this: if (flagA) foo (); ^ BODY_EXPLOC #if SOME_CONDITION_THAT_DOES_NOT_HOLD if (flagB) #endif bar (); ^ NEXT_STMT_EXPLOC This currently requires that it be multiline preprocessor logic: there must be 3 or more lines between BODY_EXPLOC and NEXT_STMT_EXPLOC for this rejection heuristic to fire. Perhaps we could tweak or reuse that heuristic, perhaps if there's an entirely blank (or all whitespace) line separating them (given that this warning is all about the "look" of the code). > These bogus warnings are pre-existing, however (i.e. not caused by this > patch). (nods) Fixing the false positives from libpng/bdwgc sounds like a separate issue and thus a separate patch then. [...snip...]