From patchwork Sat Feb 18 21:14:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9581311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A601600F6 for ; Sat, 18 Feb 2017 21:16:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BE032849C for ; Sat, 18 Feb 2017 21:16:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 407BA2875D; Sat, 18 Feb 2017 21:16:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF4E12849C for ; Sat, 18 Feb 2017 21:16:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753577AbdBRVQS (ORCPT ); Sat, 18 Feb 2017 16:16:18 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34034 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753745AbdBRVQR (ORCPT ); Sat, 18 Feb 2017 16:16:17 -0500 Received: by mail-wm0-f65.google.com with SMTP id c85so8156593wmi.1 for ; Sat, 18 Feb 2017 13:16:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=hLcri3RJBq9aEw0YKcGXGxIdcFQy8OvICVkcRhRmYKE=; b=SzARaeynKctDk8iBTthAxGoUIyeCipwP88dt0STT2a0ss48BWCHNLz5X9P0pUFZEIw f7YBMeGMk2/KT3LAm/rskc3X8rp7vNSno3mfIpekhO55Yuvo/K63QDDHGPfRGSN26qsE RTBWReT2GZBzJ+VRlCUNxg57w7F/2saL88R739N22LIKZwgeW5Ry29Pq9FJWTDmpwawE wNw3o8pHLHwZjJgGh7VJ6c32pLCqlJin030G3wEjRxqKl2pD/8xvQYlTpiz3vPBCNu19 yiRlHQW9HEc838/2XgyNmT5n996HA9gszo0Zq7ufGv30xG1UJaXTRwd3KeY44f64OOt1 ZZuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=hLcri3RJBq9aEw0YKcGXGxIdcFQy8OvICVkcRhRmYKE=; b=it0qBLbSLU2lUFNy/DLrn748DLrEwpMrxtA8pCvnaOpPxNSs0BDrhSRi1ip4qdqDPb s95FDsMn7WM6n7JD8Hxahwcvl6g4BN3wpGnRxTX+6awkYwJJpd+PdwI6nunJue1pC4Ad rmeIAB6kVybx7EtuZH4tIB2YnPtvTLchLdhEgNYQPeyhi9aMkB80kyVdeMYcHw8TnD5c KjrcogVeF7WrLS/cXt42UxATRe2HYCMq1pVxz1BxTfEX3w1n/EXKS7Q+wk0nR8Ex5y9v J53R13iVGPmbIMndMvK7CiBTI3uWJodcvjXhmzDflDqMQd3dR69yb89oB4+5kNyeOrlr VJUw== X-Gm-Message-State: AMke39l7+xvK+wKne7LEJknX1pazGyE9oVVzPMyo7JkCAwMAhRfcGeqsSOOwE/TdsDoscg== X-Received: by 10.28.172.68 with SMTP id v65mr3416657wme.49.1487452573092; Sat, 18 Feb 2017 13:16:13 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:8c2:3900:48ac:d537:1a61:c3e1]) by smtp.gmail.com with ESMTPSA id q4sm18318988wrc.35.2017.02.18.13.16.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Feb 2017 13:16:12 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Edward Cree , Luc Van Oostenryck Subject: [PATCH] make -Wbitwise operational again Date: Sat, 18 Feb 2017 22:14:03 +0100 Message-Id: <20170218211403.39019-1-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The flag -Wbitwise have no effect since patch 02a886bfa ("Introduce keyword driven attribute parsing"): the corresponding checks are now always done. Fix that by reintroducing it in the same way as it was: ignore the bitwise attribute if the flag is not set. It's less invasive that checking the flag at each place an corresponding warning is emitted. Also, to not perturb the current situation the flag is now enabled by default. Reported-by: Edward Cree Signed-off-by: Luc Van Oostenryck --- lib.c | 2 +- parse.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib.c b/lib.c index d47325243..cce027c96 100644 --- a/lib.c +++ b/lib.c @@ -216,7 +216,7 @@ static struct token *pre_buffer_begin = NULL; static struct token *pre_buffer_end = NULL; int Waddress_space = 1; -int Wbitwise = 0; +int Wbitwise = 1; int Wcast_to_as = 0; int Wcast_truncate = 1; int Wcontext = 1; diff --git a/parse.c b/parse.c index a4a126720..d07b27a21 100644 --- a/parse.c +++ b/parse.c @@ -79,6 +79,7 @@ typedef struct token *attr_t(struct token *, struct symbol *, static attr_t attribute_packed, attribute_aligned, attribute_modifier, + attribute_bitwise, attribute_address_space, attribute_context, attribute_designated_init, attribute_transparent_union, ignore_attribute, @@ -339,6 +340,10 @@ static struct symbol_op attr_mod_op = { .attribute = attribute_modifier, }; +static struct symbol_op attr_bitwise_op = { + .attribute = attribute_bitwise, +}; + static struct symbol_op attr_force_op = { .attribute = attribute_force, }; @@ -496,8 +501,8 @@ static struct init_keyword { { "noderef", NS_KEYWORD, MOD_NODEREF, .op = &attr_mod_op }, { "safe", NS_KEYWORD, MOD_SAFE, .op = &attr_mod_op }, { "force", NS_KEYWORD, .op = &attr_force_op }, - { "bitwise", NS_KEYWORD, MOD_BITWISE, .op = &attr_mod_op }, - { "__bitwise__",NS_KEYWORD, MOD_BITWISE, .op = &attr_mod_op }, + { "bitwise", NS_KEYWORD, MOD_BITWISE, .op = &attr_bitwise_op }, + { "__bitwise__",NS_KEYWORD, MOD_BITWISE, .op = &attr_bitwise_op }, { "address_space",NS_KEYWORD, .op = &address_space_op }, { "mode", NS_KEYWORD, .op = &mode_op }, { "context", NS_KEYWORD, .op = &context_op }, @@ -1105,6 +1110,13 @@ static struct token *attribute_modifier(struct token *token, struct symbol *attr return token; } +static struct token *attribute_bitwise(struct token *token, struct symbol *attr, struct decl_state *ctx) +{ + if (Wbitwise) + attribute_modifier(token, attr, ctx); + return token; +} + static struct token *attribute_address_space(struct token *token, struct symbol *attr, struct decl_state *ctx) { struct expression *expr = NULL;