- if (flags & complaint)
- {
- error_message (loc, complaint, NULL, message, args);
- complaint_issued = true;
- }
- else if (flags & fatal)
- {
- error_message (loc, fatal, _("fatal error"), message, args);
- exit (EXIT_FAILURE);
- }
- else if (flags & Wyacc)
- {
- if (yacc_flag)
- {
- error_message (loc, flags, NULL, message, args);
- complaint_issued = true;
- }
- else if (warnings_flag & Wyacc)
- {
- char* severity = Wyacc & errors_flag ? _("error") : _("warning");
- set_warning_issued (Wyacc);
- error_message (loc, flags, severity, message, args);
- }
- }
- else if (warnings_flag & flags)
- {
- char* severity = flags & errors_flag ? _("error") : _("warning");
- set_warning_issued (flags);
- error_message (loc, flags, severity, message, args);
- }
+ const char* prefix =
+ flags & fatal ? _("fatal error")
+ : flags & (errors_flag | complaint) ? _("error")
+ : _("warning");
+
+ if ((flags & complaint) && complaint_status < status_complaint)
+ complaint_status = status_complaint;
+ else if ((flags & (warnings_flag & errors_flag)) && ! complaint_status)
+ complaint_status = status_warning_as_error;
+ if (flags & (warnings_flag | fatal | complaint))
+ error_message (loc, flags, prefix, message, args);
+ if (flags & fatal)
+ exit (EXIT_FAILURE);