forked from OSchip/llvm-project
[-Wunreachable-code] handle cases where a dead 'return' may have a valid predecessor.
Fies PR19040. llvm-svn: 202892
This commit is contained in:
parent
dfb1887cc9
commit
eb862849a1
|
@ -263,6 +263,11 @@ static bool bodyEndsWithNoReturn(const CFGBlock *B) {
|
|||
}
|
||||
|
||||
static bool bodyEndsWithNoReturn(const CFGBlock::AdjacentBlock &AB) {
|
||||
// If the predecessor is a normal CFG edge, then by definition
|
||||
// the predecessor did not end with a 'noreturn'.
|
||||
if (AB.getReachableBlock())
|
||||
return false;
|
||||
|
||||
const CFGBlock *Pred = AB.getPossiblyUnreachableBlock();
|
||||
assert(!AB.isReachable() && Pred);
|
||||
return bodyEndsWithNoReturn(Pred);
|
||||
|
|
|
@ -107,3 +107,26 @@ template <> void funcToSpecialize<int>() {
|
|||
dead(); // expected-warning {{will never be executed}}
|
||||
}
|
||||
|
||||
// Handle 'try' code dominating a dead return.
|
||||
enum PR19040_test_return_t
|
||||
{ PR19040_TEST_FAILURE };
|
||||
namespace PR19040_libtest
|
||||
{
|
||||
class A {
|
||||
public:
|
||||
~A ();
|
||||
};
|
||||
}
|
||||
PR19040_test_return_t PR19040_fn1 ()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw PR19040_libtest::A ();
|
||||
} catch (...)
|
||||
{
|
||||
return PR19040_TEST_FAILURE;
|
||||
}
|
||||
return PR19040_TEST_FAILURE; // expected-warning {{will never be executed}}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue