summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/warn-consumed-analysis.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/SemaCXX/warn-consumed-analysis.cpp')
-rw-r--r--clang/test/SemaCXX/warn-consumed-analysis.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/warn-consumed-analysis.cpp b/clang/test/SemaCXX/warn-consumed-analysis.cpp
index 0618f77b5f4..28b77947898 100644
--- a/clang/test/SemaCXX/warn-consumed-analysis.cpp
+++ b/clang/test/SemaCXX/warn-consumed-analysis.cpp
@@ -14,7 +14,7 @@ template <typename T>
class CONSUMABLE(unconsumed) ConsumableClass {
T var;
- public:
+public:
ConsumableClass();
ConsumableClass(nullptr_t p) RETURN_TYPESTATE(consumed);
ConsumableClass(T val) RETURN_TYPESTATE(unconsumed);
@@ -46,6 +46,15 @@ class CONSUMABLE(unconsumed) ConsumableClass {
void consume() CONSUMES;
};
+class CONSUMABLE(unconsumed) DestructorTester {
+public:
+ DestructorTester(int);
+
+ void operator*();
+
+ ~DestructorTester() CALLABLE_WHEN("consumed");
+};
+
void baf0(const ConsumableClass<int> var);
void baf1(const ConsumableClass<int> &var);
void baf2(const ConsumableClass<int> *var);
@@ -83,6 +92,17 @@ void testInitialization() {
}
}
+void testDestruction() {
+ DestructorTester D0(42), D1(42);
+
+ *D0;
+ *D1;
+
+ D0.~DestructorTester(); // expected-warning {{invalid invocation of method '~DestructorTester' on object 'D0' while it is in the 'unconsumed' state}}
+
+ return; // expected-warning {{invalid invocation of method '~DestructorTester' on object 'D0' while it is in the 'unconsumed' state}} expected-warning {{invalid invocation of method '~DestructorTester' on object 'D1' while it is in the 'unconsumed' state}}
+}
+
void testTempValue() {
*ConsumableClass<int>(); // expected-warning {{invalid invocation of method 'operator*' on a temporary object while it is in the 'consumed' state}}
}
OpenPOWER on IntegriCloud