- res = res < warnings_flag[b] ? warnings_flag[b] : res;
- if (res == severity_warning && warnings_are_errors)
- res = severity_error;
+ {
+ res = res < warnings_flag[b] ? warnings_flag[b] : res;
+ /* If the diagnostic is enabled, and -Werror is enabled,
+ and -Wno-error=foo was not explicitly requested, this
+ is an error. */
+ if (res == severity_warning
+ && (errority_flag[b] == errority_enabled
+ || (warnings_are_errors
+ && errority_flag[b] != errority_disabled)))
+ res = severity_error;
+ }