From patchwork Wed Apr 5 21:09:21 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: 9665761 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 E659C602B5 for ; Wed, 5 Apr 2017 21:09:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D719928159 for ; Wed, 5 Apr 2017 21:09:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBEA32856A; Wed, 5 Apr 2017 21:09:46 +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 7385828159 for ; Wed, 5 Apr 2017 21:09:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934249AbdDEVJp (ORCPT ); Wed, 5 Apr 2017 17:09:45 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:36613 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934250AbdDEVJn (ORCPT ); Wed, 5 Apr 2017 17:09:43 -0400 Received: by mail-wr0-f194.google.com with SMTP id o21so946581wrb.3 for ; Wed, 05 Apr 2017 14:09:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DC4mFnk/yJ3fw6fWKdx1VQtoa4zLKVdPI+jyJ6UIZWk=; b=Nvn8hCbWdKU+bSDh/OUYrM2G5ivNuFADHn18k6WMRsQktNLlAWZ3nVpHomvlViz1ig scepFZ0TfhI7RPeFYkeJH8AmcwXtQf26ZSFB/rm07JYvEc/YOd4rk+ENNEf3GEGQnA+T Tlsn0GrAe6gVjB4I0nU43mlSfuHigDAoLrWKtPvICBquSNQAuzajvPkDW7DfCDku00Hm RtUi7X7Ztcky4tkC0KHUT8iUdnwBqCFd64mt0ka8iASnzm/OLHpIcbQFrgOwbQ4FMhAZ JLqaj5c91tm3DFT5OZ9FXtk7YqYj8DGon8+VU9YXU1LK1TsO2iv274W3ZBdU5PnEgB0b 6PhQ== 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:in-reply-to :references; bh=DC4mFnk/yJ3fw6fWKdx1VQtoa4zLKVdPI+jyJ6UIZWk=; b=fEnvhxDX8xe91GLSfPs9oqjFvZBhn54mDuQMLWzcjW7yY6V3NQmMUJgQgUfJemTYlF 41Srgs24VCuzuNrX1BlwW7GQI+hEuvvYsvXvABGnnip36v+vvxiBdZuSaPjPNHp1n3m6 iXLDQ7WN5ZPmcdIl42ua8H8iOVy20r3ItXcDqLqcMUuMsZdW9WcTH7P4dP9JQhAVmcNU dJDIf6flKq/gVpP4/Qypvtvl3HXdHIniE//q5tyJyG9pzG0TOmTo9z8DFU2/V0pOTL2Y Eqlzx/5wJXKz1sP5C1WXuPcdJ1vEcaymvETS21G2y6kTiImBK/7rSLNKxssUlUwIdIyA 6/3A== X-Gm-Message-State: AFeK/H2s+cOsjaQX06uQQ68kYKEiSuQ+utGpBSHNJAMSxfExiZMVPtqGX8rB+a1ln24peQ== X-Received: by 10.223.148.230 with SMTP id 93mr19510772wrr.34.1491426581162; Wed, 05 Apr 2017 14:09:41 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:88d:1900:fc6c:1650:1726:93b6]) by smtp.gmail.com with ESMTPSA id v29sm27592168wrv.66.2017.04.05.14.09.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Apr 2017 14:09:40 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [PATCH 3/9] finer control over error vs. warnings Date: Wed, 5 Apr 2017 23:09:21 +0200 Message-Id: <20170405210927.27948-4-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170405210927.27948-1-luc.vanoostenryck@gmail.com> References: <20170405210927.27948-1-luc.vanoostenryck@gmail.com> 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 Until now once an error is emitted, warnings are no more emitted, only others errors are. While it make some sense as once an error is encountered, things can be left in an incoherent state and could cause lots of useless warninsg because of this incoherence. However, it's also quite annoying as even unrelated warnings are so silenced. Fix this by: - use a specific flag for this: 'has_error' - make the distinction between the current phase and some previous phases (but for now we only care about parsing vs evaluation) - if an error have been emitted in a previous phase (at parsing) warning are suppressed for the current phase and all future phases - if an error is emitted in the current phase (evaluation) the flag is reset after each functions/symbols So, for example, a type error in function a() won't suppress warnings for function b(), while a parsing error still inhibit all further warnings. Signed-off-by: Luc Van Oostenryck --- evaluate.c | 1 + lib.c | 7 +++++-- lib.h | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/evaluate.c b/evaluate.c index 47eeaef2e..2cc4b1eeb 100644 --- a/evaluate.c +++ b/evaluate.c @@ -3214,6 +3214,7 @@ void evaluate_symbol_list(struct symbol_list *list) struct symbol *sym; FOR_EACH_PTR(list, sym) { + has_error &= ~ERROR_CURR_PHASE; evaluate_symbol(sym); check_duplicates(sym); } END_FOR_EACH_PTR(sym); diff --git a/lib.c b/lib.c index 272d2c88a..d6c893e71 100644 --- a/lib.c +++ b/lib.c @@ -47,6 +47,7 @@ int verbose, optimize, optimize_size, preprocessing; int die_if_error = 0; +int has_error = 0; #ifndef __GNUC__ # define __GNUC__ 2 @@ -133,7 +134,7 @@ static void do_error(struct position pos, const char * fmt, va_list args) die_if_error = 1; show_info = 1; /* Shut up warnings after an error */ - max_warnings = 0; + has_error |= ERROR_CURR_PHASE; if (errors > 100) { static int once = 0; show_info = 0; @@ -158,7 +159,7 @@ void warning(struct position pos, const char * fmt, ...) return; } - if (!max_warnings) { + if (!max_warnings || has_error) { show_info = 0; return; } @@ -1208,6 +1209,8 @@ struct symbol_list * sparse(char *filename) { struct symbol_list *res = __sparse(filename); + if (has_error & ERROR_CURR_PHASE) + has_error = ERROR_PREV_PHASE; /* Evaluate the complete symbol list */ evaluate_symbol_list(res); diff --git a/lib.h b/lib.h index 134e56040..7ed889c60 100644 --- a/lib.h +++ b/lib.h @@ -97,6 +97,10 @@ extern void sparse_error(struct position, const char *, ...) FORMAT_ATTR(2); extern void error_die(struct position, const char *, ...) FORMAT_ATTR(2) NORETURN_ATTR; extern void expression_error(struct expression *, const char *, ...) FORMAT_ATTR(2); +#define ERROR_CURR_PHASE (1 << 0) +#define ERROR_PREV_PHASE (1 << 1) +extern int has_error; + extern void add_pre_buffer(const char *fmt, ...) FORMAT_ATTR(1); extern int preprocess_only;