https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121002

            Bug ID: 121002
           Summary: d: -Wno-error=deprecated does not overwrite a previous
                    -Werror
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: a.horodniceanu at proton dot me
  Target Milestone: ---

With a sample program
-----
deprecated void foo () {}
void bar () { foo; }
-----

And invoking gdc with both -Werror and -Wno-error=deprecated it still results
in the deprecation being treated as an error:
-----
$ gdc -fsyntax-only a.d  -Werror -Wno-error=deprecated
a.d:2:15: error: function ‘a.foo’ is deprecated
    2 | void bar () { foo; }
      |               ^
-----

One can also notice that gdc doesn't show the warning that caused the error.
Compare with:
----
$ gdc -fsyntax-only a.d  -Werror=deprecated
a.d:2:15: error: function ‘a.foo’ is deprecated [-Werror=deprecated]
    2 | void bar () { foo; }
      |               ^
d21: some warnings being treated as errors
----

Where the [-Werror=deprecated] link appears and, at the end, there's the `d21:
some warnings being treated as errors` message.

---------------------

This seems to be caused by d-lang.cc setting global.params.useWarnings to
DIAGNOSTICerror in
---
    case OPT_Werror:
      break;
      if (value)
        global.params.useWarnings = DIAGNOSTICerror;
      break;
---
which is then picked up by d-diagnostic.cc and, instead of issuing a warning,
the message is bumped to an error:
---
  else if (kind == ErrorKind::deprecation)
    {
      if (global.params.useDeprecated == DIAGNOSTICerror)
        return verrorReport (loc, format, ap, ErrorKind::error, prefix1,
                             prefix2);
---

It sounds like a fix if the d glue code would only set useDeprecated and
useWarning to either info or off, and allow the gcc code to bump the severity
of warnings to errors. I'm not sure about this so it's just a suggestion

Reply via email to