From: Tony Camuso <tcamuso@redhat.com>
To: sparse@chrisli.org, linux-sparse@vger.kernel.org
Cc: tcamuso@redhat.com
Subject: [PATCH 3/3] Add NOWARN and NOERR compile conditions
Date: Wed, 29 Jul 2015 20:26:41 -0400 [thread overview]
Message-ID: <1438216001-8862-4-git-send-email-tcamuso@redhat.com> (raw)
In-Reply-To: <1438216001-8862-1-git-send-email-tcamuso@redhat.com>
Allows building sparse to avert reporting semantic problems, e.g.
using sparse as a tokenizer to create a graph of KABI symbols and
their dependencies.
Signed-off-by: Tony Camuso <tcamuso@redhat.com>
---
lib.c | 21 +++++++++++++++++++++
parse.c | 12 ++++++++++++
2 files changed, 33 insertions(+)
diff --git a/lib.c b/lib.c
index 8dc5bcf..cb10bce 100644
--- a/lib.c
+++ b/lib.c
@@ -48,6 +48,13 @@
int verbose, optimize, optimize_size, preprocessing;
int die_if_error = 0;
+#ifdef NOWARN
+#pragma message "Built with NOWARN"
+#endif
+#ifdef NOERR
+#pragma message "Built with NOERR"
+#endif
+
#ifndef __GNUC__
# define __GNUC__ 2
# define __GNUC_MINOR__ 95
@@ -103,6 +110,9 @@ unsigned int hexval(unsigned int c)
static void do_warn(const char *type, struct position pos, const char * fmt, va_list args)
{
+#ifdef NOWARN
+ return;
+#else
static char buffer[512];
const char *name;
@@ -111,9 +121,12 @@ static void do_warn(const char *type, struct position pos, const char * fmt, va_
fprintf(stderr, "%s:%d:%d: %s%s\n",
name, pos.line, pos.pos, type, buffer);
+#endif
}
+#ifndef NOWARN
static int max_warnings = 100;
+#endif
static int show_info = 1;
void info(struct position pos, const char * fmt, ...)
@@ -129,6 +142,9 @@ void info(struct position pos, const char * fmt, ...)
static void do_error(struct position pos, const char * fmt, va_list args)
{
+#ifdef NOERR
+ return;
+#else
static int errors = 0;
die_if_error = 1;
show_info = 1;
@@ -145,10 +161,14 @@ static void do_error(struct position pos, const char * fmt, va_list args)
do_warn("error: ", pos, fmt, args);
errors++;
+#endif
}
void warning(struct position pos, const char * fmt, ...)
{
+#ifdef NOWARN
+ return;
+#else
va_list args;
if (Wsparse_error) {
@@ -171,6 +191,7 @@ void warning(struct position pos, const char * fmt, ...)
va_start(args, fmt);
do_warn("warning: ", pos, fmt, args);
va_end(args);
+#endif
}
void sparse_error(struct position pos, const char * fmt, ...)
diff --git a/parse.c b/parse.c
index 02275d8..f773fe8 100644
--- a/parse.c
+++ b/parse.c
@@ -44,6 +44,13 @@
#include "expression.h"
#include "target.h"
+#ifdef NOWARN
+#pragma message "Built with NOWARN"
+#endif
+#ifdef NOERR
+#pragma message "Built with NOERR"
+#endif
+
static struct symbol_list **function_symbol_list;
struct symbol_list *function_computed_target_list;
struct statement_list *function_computed_goto_list;
@@ -2746,8 +2753,13 @@ struct token *external_declaration(struct token *token, struct symbol_list **lis
/* Just a type declaration? */
if (!ident) {
+
+#if defined NOWARN || defined NOERR
+ return token->next;
+#else
warning(token->pos, "missing identifier in declaration");
return expect(token, ';', "at the end of type declaration");
+#endif
}
/* type define declaration? */
--
2.4.3
next prev parent reply other threads:[~2015-07-30 0:26 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-30 0:26 [PATCH 0/3] Minor enhancements and fixes Tony Camuso
2015-07-30 0:26 ` [PATCH 1/3] .gitignore: add cscope and Qt project files Tony Camuso
2015-08-03 17:41 ` [PATCH 1/3 v2] " Tony Camuso
2015-08-08 3:58 ` Christopher Li
2015-08-10 11:18 ` Tony Camuso
2015-08-10 12:33 ` [PATCH 1/3 v3] " Tony Camuso
2015-07-30 0:26 ` [PATCH 2/3] c2xml.c, parse.c: gcc 5+ stricter case statement parsing Tony Camuso
2015-08-04 12:06 ` [PATCH 2/3 v2] Handle all enum members in case statements Tony Camuso
2015-08-04 23:31 ` Christopher Li
2015-08-04 23:52 ` Tony Camuso
[not found] ` <CANeU7Q=QAtRqDP36k8uOd9_XgzqjJ0du5SO2WpMEcjp8+mg3CQ@mail.gmail.com>
2015-08-10 11:16 ` Tony Camuso
2015-08-10 12:35 ` [PATCH 2/3 v3] Add default case to switches on enum variables Tony Camuso
2015-07-30 0:26 ` Tony Camuso [this message]
2015-07-30 2:55 ` [PATCH 3/3] Add NOWARN and NOERR compile conditions Josh Triplett
2015-07-30 11:45 ` Tony Camuso
2015-07-31 23:46 ` Christopher Li
2015-08-01 11:09 ` Tony Camuso
2015-08-01 17:52 ` Josh Triplett
2015-08-01 18:45 ` Christopher Li
2015-08-02 13:42 ` Tony Camuso
2015-08-02 23:16 ` Tony Camuso
2015-08-02 23:22 ` Tony Camuso
2015-08-03 11:23 ` Nicolai Stange
2015-08-03 11:47 ` Tony Camuso
2015-07-31 17:07 ` Tony Camuso
2015-07-31 17:12 ` [PATCH 3/3 V2] lib.c: add Wall_off switch Tony Camuso
2015-07-31 18:01 ` Tony Camuso
2015-07-31 19:27 ` [PATCH 3/3 V3] Add Wall_off switch to disable errors and warnings Tony Camuso
2015-08-01 12:59 ` Sam Ravnborg
2015-08-01 13:52 ` Tony Camuso
2015-08-03 16:35 ` [PATCH 3/3 v4] " Tony Camuso
2016-01-05 1:19 ` Luc Van Oostenryck
2016-01-13 14:39 ` Tony Camuso
2015-08-03 18:10 ` [PATCH 0/3] Minor enhancements and fixes Tony Camuso
2015-12-02 18:52 ` Tony Camuso
2016-02-02 18:54 ` Christopher Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438216001-8862-4-git-send-email-tcamuso@redhat.com \
--to=tcamuso@redhat.com \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).