[cfe-dev] Is -Wno-return-type a warning or error?

Dan Liew via cfe-dev cfe-dev at lists.llvm.org
Sat Oct 31 00:31:47 PDT 2015


Hi,

On 29 October 2015 at 15:10, David Blaikie <dblaikie at gmail.com> wrote:
> Intentional, I believe. We do have some warning which default to being
> errors. I'm not sure of the specifics of the c language standard in this
> case, but perhaps there's some case where this is not UB (if the return is
> never executed, perhaps) so it may not technically be invalid c.

Thanks for the reply. I'm pretty sure that ``return;`` in ``foo()`` is
disallowed by C99 so I agree with Clang emitting an error here.

My concern was more was more how the Clang driver behaves. I've always
thought as warnings and errors as a dichotomy.
However ``-Wreturn-type`` is an error but can be suppressed like a
warning so it is neither an error nor a warning.

If I think about from an implementation perspective it makes sense. We
have the ``-Wreturn-type`` warning that implements an analysis that
will sometimes will be a warning (e.g. If I remove the ``return;``
statement in ``foo();`` I just get a warning) and sometimes
will raise an error. It's just feels a little odd from the user
perspective that a Clang error can be suppressed. I would expect
for Clang to treat something that it thinks is an error as
insuppressible. I guess passing ``-Wno-return-type`` disables the
analysis running completely.

If the Clang developers are happy with this behaviour then there is
nothing to be done. I guess "fixing it" would be a bit problematic
anyway because it would imply
you would need to run all warning analyses just to see if any of them
raise an error (even when ``-w`` is passed).



More information about the cfe-dev mailing list