Record the position of attributes.
[cparser] / diagnostic.c
index 6376abb..b2ba266 100644 (file)
 #include "warning.h"
 
 /** Number of occurred diagnostics. */
-unsigned diagnostic_count    = 0;
+unsigned diagnostic_count        = 0;
 /** Number of occurred errors. */
-unsigned error_count         = 0;
+unsigned error_count             = 0;
 /** Number of occurred warnings. */
-unsigned warning_count       = 0;
-bool     show_column         = true;
+unsigned warning_count           = 0;
+bool     show_column             = true;
+bool     diagnostics_show_option = true;
 
 static const source_position_t *curr_pos = NULL;
 
@@ -245,26 +246,25 @@ void warningf(warning_t const warn, source_position_t const* pos, char const *co
        va_list ap;
        va_start(ap, fmt);
        warning_switch_t const *const s = get_warn_switch(warn);
-       switch (s->level) {
-               case WARN_LEVEL_OFF:
-                       break;
-
+       switch (s->state) {
                        char const* kind;
-               case WARN_LEVEL_ON:
+               case WARN_STATE_ON:
                        if (is_warn_on(WARN_ERROR)) {
-               case WARN_LEVEL_ERROR:
+               case WARN_STATE_ON | WARN_STATE_ERROR:
                                ++error_count;
                                kind = "error";
                        } else {
+               case WARN_STATE_ON | WARN_STATE_NO_ERROR:
                                ++warning_count;
                                kind = "warning";
                        }
                        diagnosticposvf(pos, kind, fmt, ap);
-                       fprintf(stderr, " [-W%s]\n", s->name);
+                       if (diagnostics_show_option)
+                               fprintf(stderr, " [-W%s]\n", s->name);
                        break;
 
                default:
-                       panic("invalid warning level");
+                       break;
        }
        va_end(ap);
 }