aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/return-noreturn.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/return-noreturn.cpp')
-rw-r--r--test/SemaCXX/return-noreturn.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/SemaCXX/return-noreturn.cpp b/test/SemaCXX/return-noreturn.cpp
index 617de0089585d..531dc23995d27 100644
--- a/test/SemaCXX/return-noreturn.cpp
+++ b/test/SemaCXX/return-noreturn.cpp
@@ -40,6 +40,14 @@ namespace abort_struct_complex_cfgs {
switch (x) default: L1: L2: case 4: { pr6884_abort_struct(); }
}
+ // FIXME: detect noreturn destructors triggered by calls to delete.
+ int f7(int x) {
+ switch (x) default: L1: L2: case 4: {
+ pr6884_abort_struct *p = new pr6884_abort_struct();
+ delete p;
+ }
+ } // expected-warning {{control reaches end of non-void function}}
+
// Test that these constructs work even when extraneous blocks are created
// before and after the switch due to implicit destructors.
int g1(int x) {
@@ -138,3 +146,25 @@ void PR9412_f() {
PR9412_t<PR9412_Exact>(); // expected-note {{in instantiation of function template specialization 'PR9412_t<0>' requested here}}
}
+#if __cplusplus >= 201103L
+namespace LambdaVsTemporaryDtor {
+ struct Y { ~Y(); };
+ struct X { template<typename T> X(T, Y = Y()) {} };
+
+ struct Fatal { ~Fatal() __attribute__((noreturn)); };
+ struct FatalCopy { FatalCopy(); FatalCopy(const FatalCopy&, Fatal F = Fatal()); };
+
+ void foo();
+
+ int bar() {
+ X work([](){ Fatal(); });
+ foo();
+ } // expected-warning {{control reaches end of non-void function}}
+
+ int baz() {
+ FatalCopy fc;
+ X work([fc](){});
+ foo();
+ } // ok, initialization of lambda does not return
+}
+#endif