aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-18 18:10:31 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-18 18:10:31 +0200
commitdd6c3980de7daa8112a0791df730b04f2fcb3c5c (patch)
treeab3404dc182e683b806a133b0fe15a4a547adaa2
parenta30da6a51cc240ca1c6966db1b77cf24e0701758 (diff)
parent7d648be9208b26bee94ecc0dad8511c92a7fe339 (diff)
downloadsparse-dd6c3980de7daa8112a0791df730b04f2fcb3c5c.tar.gz
Merge branch 'error-inval-num'
* teach sparse about -fmax-errors * syntax errors in numbers are not fatal
-rw-r--r--expression.c5
-rw-r--r--lib.c2
-rw-r--r--options.c8
-rw-r--r--options.h1
-rw-r--r--sparse.16
5 files changed, 20 insertions, 2 deletions
diff --git a/expression.c b/expression.c
index ecbdd18e..221d7780 100644
--- a/expression.c
+++ b/expression.c
@@ -379,7 +379,10 @@ Float:
return;
Enoint:
- error_die(expr->pos, "constant %s is not a valid number", show_token(token));
+ sparse_error(expr->pos, "constant %s is not a valid number", show_token(token));
+ expr->type = EXPR_VALUE;
+ expr->value = 0;
+ expr->ctype = &int_ctype;
}
static struct token *generic_selection(struct token *token, struct expression **tree)
diff --git a/lib.c b/lib.c
index d4f4dd30..4e8d7b45 100644
--- a/lib.c
+++ b/lib.c
@@ -90,7 +90,7 @@ static void do_error(struct position pos, const char * fmt, va_list args)
return;
/* Shut up warnings after an error */
has_error |= ERROR_CURR_PHASE;
- if (errors > 100) {
+ if (errors > fmax_errors) {
static int once = 0;
show_info = 0;
if (once)
diff --git a/options.c b/options.c
index b2eb7a99..a2e15bb7 100644
--- a/options.c
+++ b/options.c
@@ -73,6 +73,7 @@ int dump_macros_only = 0;
unsigned long fdump_ir;
int fhosted = 1;
+unsigned int fmax_errors = 100;
unsigned int fmax_warnings = 100;
int fmem_report = 0;
unsigned long long fmemcpy_max_count = 100000;
@@ -492,6 +493,12 @@ static int handle_fmemcpy_max_count(const char *arg, const char *opt, const stru
return 1;
}
+static int handle_fmax_errors(const char *arg, const char *opt, const struct flag *flag, int options)
+{
+ opt_uint(arg, opt, &fmax_errors, OPTNUM_UNLIMITED);
+ return 1;
+}
+
static int handle_fmax_warnings(const char *arg, const char *opt, const struct flag *flag, int options)
{
opt_uint(arg, opt, &fmax_warnings, OPTNUM_UNLIMITED);
@@ -504,6 +511,7 @@ static struct flag fflags[] = {
{ "freestanding", &fhosted, NULL, OPT_INVERSE },
{ "hosted", &fhosted },
{ "linearize", NULL, handle_fpasses, PASS_LINEARIZE },
+ { "max-errors=", NULL, handle_fmax_errors },
{ "max-warnings=", NULL, handle_fmax_warnings },
{ "mem-report", &fmem_report },
{ "memcpy-max-count=", NULL, handle_fmemcpy_max_count },
diff --git a/options.h b/options.h
index 7fd01ec6..070c0dd8 100644
--- a/options.h
+++ b/options.h
@@ -72,6 +72,7 @@ extern int dump_macros_only;
extern unsigned long fdump_ir;
extern int fhosted;
+extern unsigned int fmax_errors;
extern unsigned int fmax_warnings;
extern int fmem_report;
extern unsigned long long fmemcpy_max_count;
diff --git a/sparse.1 b/sparse.1
index 19c8c4e3..399a63fa 100644
--- a/sparse.1
+++ b/sparse.1
@@ -20,6 +20,12 @@ off those warnings, pass the negation of the associated warning option,
.
.SH WARNING OPTIONS
.TP
+.B \-fmax-errors=COUNT
+Set the maximum number of displayed errors to COUNT, which should be
+a numerical value or 'unlimited'.
+The default limit is 100.
+.
+.TP
.B \-fmax-warnings=COUNT
Set the maximum number of displayed warnings to COUNT, which should be
a numerical value or 'unlimited'.