[PATCH] NoReturn Warning: Removed Warning for Unreachable Return

Michael Bao mike.h.bao at gmail.com
Sun Jan 5 14:34:18 PST 2014

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?

More information about the cfe-commits mailing list