- 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)
- {
- set_warning_issued ();
- error_message (loc, flags, _("warning"), message, args);
- }
- }
- else if (warnings_flag & flags)
- {
- set_warning_issued ();
- error_message (loc, flags, _("warning"), 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);