]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite, c++, coroutines: Correct a test intent.
authorIain Sandoe <iain@sandoe.co.uk>
Sat, 31 Aug 2024 11:42:36 +0000 (12:42 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Sat, 31 Aug 2024 16:31:39 +0000 (17:31 +0100)
The intention of the series of tests numberef pr95615-* is to
verify that entities created by the ramp and potentially needing
destruction are correctly handled when exceptions are thrown.
Because of a typo, one case was not being checked correctly (the
return object).  This patch amends the check to test that the
returned object is properly deleted.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/torture/pr95615.inc: Check tha the
task object produced by get_return_object is correctly
deleted on exception.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/testsuite/g++.dg/coroutines/torture/pr95615.inc

index 5fc22430e9917c20c5e12435d1da5a08094589b1..b6f78fb15b9f9acca76ece71775d225e66fba20b 100644 (file)
@@ -12,11 +12,11 @@ namespace std {
 
 bool frame_live = false;
 bool promise_live = false;
-bool gro_live = false;
 
 struct X {};
 
 int Y_live = 0;
+int task_live = 0;
 
 struct Y
 {
@@ -85,7 +85,6 @@ struct task {
 #if GET_RETURN_OBJECT_THROWS
             throw X{};
 #endif
-           bool gro_live = true;
             return task{};
         }
 
@@ -96,12 +95,12 @@ struct task {
         }
     };
 
-    task() { std::puts("task()"); }
-    ~task() { std::puts("~task()"); }
-    task(task&&) { std::puts("task(task&&)"); }
+    task() { std::puts("task()");  task_live++; }
+    ~task() { std::puts("~task()"); task_live--; }
+    task(task&&) { std::puts("task(task&&)"); task_live++;  }
 };
 
-task f(Y Val) {
+task f(Y Val __attribute__((__unused__))) {
     co_return;
 }
 
@@ -112,8 +111,8 @@ int main() {
         f(Val);
     } catch (X) {
         std::puts("caught X");
-        if (gro_live)
-          std::puts("gro live"), failed = true;
+        if (task_live)
+          std::puts("task live"), failed = true;
         if (promise_live)
           std::puts("promise live"), failed = true;
         if (frame_live)