[PATCH] NoReturn Warning: Removed Warning for Unreachable Return

Richard Smith metafoo at gmail.com
Mon Jan 6 13:32:26 PST 2014


On Sun Jan 05 2014 at 2:36:56 PM, Michael Bao <mike.h.bao at gmail.com> wrote:

> On Sat, Jan 4, 2014 at 1:39 PM, Aaron Ballman <aaron at aaronballman.com>
> wrote:
> >
> > That makes sense as to why you'd move it, but I'm still concerned
> > about this changing the semantics. For instance, this can now fire for
> > ObjCMethodDecl objects, where it used to not be possible. This could
> > be a bug fix, but it would also require further testing (and
> > confirmation from some of the ObjC experts as to whether this is
> > desirable).
>
> Hm, wouldn't the wrap around the diagnostic call with
>
> if (const FunctionDecl *FD = getCurFunctionDecl()) {
> }
>
> prevent it from firing for ObjCMethodDecl objects?
>
> But looking at the bigger picture, it seems like Joerg was more so
> envisioning that the warning be replaced with a better warning in the
> case that the 'return' statement is unreachable. However, the default
> behavior for the unreachable code warning is to ignore it unless
> -Wunreachable-code is passed into the compiler.
>
> So in the case that the 'return' statement is reachable, we definitely
> want to emit the 'warn_noreturn_function_has_return_expr' warning.
>
> However, when it isn't, I think it would be best to only emit a
> warning only if -Wunreachable-code is passed into the compiler. Does
> that sound reasonable?


That sounds appropriate. That's what your original patch did, right?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140106/59def05b/attachment.html>


More information about the cfe-commits mailing list