aboutsummaryrefslogtreecommitdiff
path: root/lib.c
diff options
context:
space:
mode:
authorPavel Roskin <proski@gnu.org>2006-08-01 13:50:08 -0400
committerJosh Triplett <josh@freedesktop.org>2006-12-05 02:51:26 -0800
commit5e7a92300a348e8a47bb488cd19be626346d6460 (patch)
treea28f53cd3f1b367f9e3c320ffdc28a7682e9bd6c /lib.c
parentGenerate and install a pkg-config file. Add DESTDIR support to Makefile. (diff)
downloadsparse-5e7a92300a348e8a47bb488cd19be626346d6460.tar.gz
sparse-5e7a92300a348e8a47bb488cd19be626346d6460.tar.bz2
sparse-5e7a92300a348e8a47bb488cd19be626346d6460.zip
Support -Wall flag
If -Wall is specified, enable all warnings except those explicitly disabled by -Wno-* switches. Signed-off-by: Pavel Roskin <proski@gnu.org>
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/lib.c b/lib.c
index 171ce59..51c415d 100644
--- a/lib.c
+++ b/lib.c
@@ -342,24 +342,37 @@ static const struct warning {
{ "uninitialized", &Wuninitialized },
};
+enum {
+ WARNING_OFF,
+ WARNING_ON,
+ WARNING_FORCE_OFF
+};
+
static char **handle_switch_W(char *arg, char **next)
{
- int no = 0;
+ int flag = WARNING_ON;
char *p = arg + 1;
unsigned i;
+ if (!strcmp(p, "all")) {
+ for (i = 0; i < sizeof(warnings) / sizeof(warnings[0]); i++) {
+ if (*warnings[i].flag != WARNING_FORCE_OFF)
+ *warnings[i].flag = WARNING_ON;
+ }
+ }
+
// Prefixes "no" and "no-" mean to turn warning off.
if (p[0] == 'n' && p[1] == 'o') {
p += 2;
if (p[0] == '-')
p++;
- no = 1;
+ flag = WARNING_FORCE_OFF;
}
for (i = 0; i < sizeof(warnings) / sizeof(warnings[0]); i++) {
if (!strcmp(p,warnings[i].name)) {
- *warnings[i].flag = !no;
+ *warnings[i].flag = flag;
return next;
}
}
@@ -368,6 +381,16 @@ static char **handle_switch_W(char *arg, char **next)
return next;
}
+static void handle_switch_W_finalize(void)
+{
+ unsigned i;
+
+ for (i = 0; i < sizeof(warnings) / sizeof(warnings[0]); i++) {
+ if (*warnings[i].flag == WARNING_FORCE_OFF)
+ *warnings[i].flag = WARNING_OFF;
+ }
+}
+
static char **handle_switch_U(char *arg, char **next)
{
const char *name = arg + 1;
@@ -632,6 +655,7 @@ struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list
}
add_ptr_list_notag(filelist, arg);
}
+ handle_switch_W_finalize();
list = NULL;
if (!ptr_list_empty(filelist)) {