diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-03-02 20:32:29 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-03-02 20:32:29 +0000 |
commit | c9f8f5a726bbb562e4b2d4b19d66e6202dcb2657 (patch) | |
tree | e9e0f5f97ae878865cd4484c2ec9c17bd899e545 /test | |
parent | 41ba26701de859128ebe48a957c286e5dc01475f (diff) |
Introduce CFGImplicitDtor::isNoReturn() to query whether a destructor actually returns. Use this for -Wreturn-type to prune false positives reported in PR 6884.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126875 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/SemaCXX/return-noreturn.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/test/SemaCXX/return-noreturn.cpp b/test/SemaCXX/return-noreturn.cpp index 7e0a69c266..890fb9017c 100644 --- a/test/SemaCXX/return-noreturn.cpp +++ b/test/SemaCXX/return-noreturn.cpp @@ -1,18 +1,29 @@ // RUN: %clang_cc1 %s -fsyntax-only -verify -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code -// XFAIL: * // A destructor may be marked noreturn and should still influence the CFG. -namespace PR6884 { - struct abort_struct { - abort_struct() {} // Make this non-POD so the destructor is invoked. - ~abort_struct() __attribute__((noreturn)); - }; +void pr6884_abort() __attribute__((noreturn)); - int f() { - abort_struct(); - } +struct pr6884_abort_struct { + pr6884_abort_struct() {} + ~pr6884_abort_struct() __attribute__((noreturn)) { pr6884_abort(); } +}; + +int pr6884_f(int x) { + switch (x) { default: pr6884_abort(); } +} + +int pr6884_g(int x) { + switch (x) { default: pr6884_abort_struct(); } +} + +int pr6884_g_positive(int x) { + switch (x) { default: ; } +} // expected-warning {{control reaches end of non-void function}} - int f2() { - abort_struct s; +int pr6884_h(int x) { + switch (x) { + default: { + pr6884_abort_struct a; + } } } |