scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit c231c04f8d22b3b6a46fa49c7da5f7a829380a02
parent 37c543332c819df9b16eceb732a727992af7a7d4
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat,  9 May 2015 17:55:04 +0200

Add limit to the number of errors

This limit helps in the case of inifinite errors, and after 10
errors nobody read more.

Diffstat:
cc1/error.c | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/cc1/error.c b/cc1/error.c @@ -7,7 +7,10 @@ #include "../inc/cc.h" #include "cc1.h" +#define MAXERRNUM 10 + extern uint8_t failure; +static uint8_t nerrors; static void warn_helper(int8_t flag, char *fmt, va_list va) @@ -18,6 +21,10 @@ warn_helper(int8_t flag, char *fmt, va_list va) (flag < 0) ? "error" : "warning", filename(), fileline()); vfprintf(stderr, fmt, va); putc('\n', stderr); + if (flag < 0 && nerrors++ == MAXERRNUM) { + fputs("too many errors\n", stderr); + exit(-1); + } } void