projects
/
cparser
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Accept -Wno-all, -Wno-extra and -Wno-unused like GCC.
[cparser]
/
diagnostic.c
diff --git
a/diagnostic.c
b/diagnostic.c
index
fab118e
..
abfa8eb
100644
(file)
--- a/
diagnostic.c
+++ b/
diagnostic.c
@@
-6,9
+6,7
@@
#include "diagnostic.h"
#include "token_t.h"
#include "type.h"
#include "diagnostic.h"
#include "token_t.h"
#include "type.h"
-
-
-//#define ABORT_ON_ERROR
+#include "warning.h"
/** Number of occurred diagnostics. */
unsigned diagnostic_count = 0;
/** Number of occurred diagnostics. */
unsigned diagnostic_count = 0;
@@
-16,6
+14,8
@@
unsigned diagnostic_count = 0;
unsigned error_count = 0;
/** Number of occurred warnings. */
unsigned warning_count = 0;
unsigned error_count = 0;
/** Number of occurred warnings. */
unsigned warning_count = 0;
+/** true if warnings should be inhibited */
+bool inhibit_all_warnings = false;
/**
* Issue a diagnostic message.
/**
* Issue a diagnostic message.
@@
-136,28
+136,46
@@
void diagnosticf(const char *const fmt, ...)
va_end(ap);
}
va_end(ap);
}
-void errorf(const source_position_t pos, const char *const fmt, ...)
+static void errorvf(const source_position_t pos,
+ const char *const fmt, va_list ap)
{
{
- ++error_count;
fprintf(stderr, "%s:%u: error: ", pos.input_name, pos.linenr);
fprintf(stderr, "%s:%u: error: ", pos.input_name, pos.linenr);
+ ++error_count;
+ diagnosticvf(fmt, ap);
+ fputc('\n', stderr);
+
+ if (warning.fatal_errors)
+ exit(EXIT_FAILURE);
+}
+
+void errorf(const source_position_t pos, const char *const fmt, ...)
+{
va_list ap;
va_start(ap, fmt);
va_list ap;
va_start(ap, fmt);
-
diagnosticvf(
fmt, ap);
+
errorvf(pos,
fmt, ap);
va_end(ap);
va_end(ap);
- fputc('\n', stderr);
+}
-#ifdef ABORT_ON_ERROR
- abort();
-#endif
+static void warningvf(const source_position_t pos,
+ const char *const fmt, va_list ap)
+{
+ fprintf(stderr, "%s:%u: warning: ", pos.input_name, pos.linenr);
+ ++warning_count;
+ diagnosticvf(fmt, ap);
+ fputc('\n', stderr);
}
void warningf(const source_position_t pos, const char *const fmt, ...)
{
}
void warningf(const source_position_t pos, const char *const fmt, ...)
{
- ++warning_count;
- fprintf(stderr, "%s:%u: warning: ", pos.input_name, pos.linenr);
+ if (inhibit_all_warnings)
+ return;
+
va_list ap;
va_start(ap, fmt);
va_list ap;
va_start(ap, fmt);
- diagnosticvf(fmt, ap);
+ if (warning.s_are_errors) {
+ errorvf(pos, fmt, ap);
+ } else {
+ warningvf(pos, fmt, ap);
+ }
va_end(ap);
va_end(ap);
- fputc('\n', stderr);
}
}