llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.33k stars 12.13k forks source link

Use of return in functions with noreturn #11014

Open jsonn opened 13 years ago

jsonn commented 13 years ago
Bugzilla Link 10642
Version trunk
OS Linux
CC @tkremenek

Extended Description

Consider this:

include

attribute((noreturn)) int foo(void) { exit(1); return 0; }

At the moment, this triggers:

warning: function 'foo' declared 'noreturn' should not return [-Winvalid-noreturn]

I think this warning is bogus and misleading.

(1) The return is dead code, but might exist to help more stupid compilers that can't figure out the noreturn property of exit.

(2) noreturn on a function with a return value other than void is questionable. A warning for that would be nice.

jsonn commented 8 years ago

Still applies with r278913

jsonn commented 10 years ago

This still applies with r197332.

tkremenek commented 13 years ago

cloned to rdar://problem/9958379

tkremenek commented 13 years ago

This is gross code, but we can certainly fix this since (I believe) we already do a reachability analysis.