]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite, c++, coroutines: Avoid 'unused' warnings [NFC].
authorIain Sandoe <iain@sandoe.co.uk>
Sat, 31 Aug 2024 11:53:40 +0000 (12:53 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Sat, 31 Aug 2024 16:33:31 +0000 (17:33 +0100)
The 'torture' section of the coroutine tests is primarily about checking
correct operation of the generated code.  It should, ideally, be possible
to run this part of the testsuite with '-Wall' and expect no fails.  In
the case that we wish to test for a specific diagnostic (and that it does
not appear over a range of optimisation/debug conditions) then we should
make that explict (as done, for example, in pr109867.C).

The tests amended here have warnings because of unused entities; in many
cases those are relevant to the test, and so we just mark them with
__attribute__((__unused__)).

We amend the debug output in coro.h to avoid similar warnings when print
output is disabled (the default).

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/coro.h: Use a variadic macro for PRINTF to
avoid unused warnings when output is disabled.
* g++.dg/coroutines/torture/co-await-04-control-flow.C: Avoid
unused warnings.
* g++.dg/coroutines/torture/co-ret-13-template-2.C: Likewise.
* g++.dg/coroutines/torture/exceptions-test-01-n4849-a.C: Likewise.
* g++.dg/coroutines/torture/local-var-04-hiding-nested-scopes.C:
Likewise.
* g++.dg/coroutines/torture/pr109867.C: Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/testsuite/g++.dg/coroutines/coro.h
gcc/testsuite/g++.dg/coroutines/torture/co-await-04-control-flow.C
gcc/testsuite/g++.dg/coroutines/torture/co-ret-13-template-2.C
gcc/testsuite/g++.dg/coroutines/torture/exceptions-test-01-n4849-a.C
gcc/testsuite/g++.dg/coroutines/torture/local-var-04-hiding-nested-scopes.C
gcc/testsuite/g++.dg/coroutines/torture/pr109867.C

index 491177f0cfd5fa31b01fb85b539fbfdf188c88fd..71c1cd73207dc4b9de1556dca0a8f1b5aa45ae36 100644 (file)
@@ -135,9 +135,9 @@ namespace coro = std;
 
 #ifndef OUTPUT
 #  define PRINT(X)
-#  define PRINTF (void)
+#  define PRINTF(...)
 #else
 #include <stdio.h>
 #  define PRINT(X) puts(X)
-#  define PRINTF printf
+#  define PRINTF(...) printf(__VA_ARGS__)
 #endif
index fd201f904816db5b4d1081198d081596d662dfb8..32d9c982d4a10e6415d02b50065a48a6bc441611 100644 (file)
@@ -1,4 +1,5 @@
 //  { dg-do run }
+//  { dg-additional-options "-Wno-unused-label" }
 
 // Check correct operation of await transform.
 
index 9d4a4de8ebe8afa302c756e65056dd0202315f50..8a8d2d6fa5d9117d2f692569fb46731c32ace4c5 100644 (file)
@@ -13,7 +13,7 @@ coro1
 f (T y) noexcept
 {
   PRINT ("coro1: about to return");
-  T x = y;
+  __attribute__((__unused__)) T x = y;
   co_return 3;
 }
 
index 6433b62109fcc5517e3c99d16ef735e11c488ec1..c5a0a38b2ca21fb273fd5a5b810d39d49a908a4b 100644 (file)
@@ -116,7 +116,6 @@ struct coro1 {
 struct coro1
 n4849_ia_thrower (int k)
 {
-  int caught = 0;
   PRINT ("f: about to return 22");
   co_return 22;
 }
index 419eb6b64673552d18ed0c2555b87af7b3b45c7c..04c1ab362d2d2755cf21a424d366cc35c7097be0 100644 (file)
@@ -13,9 +13,9 @@ f (int start) noexcept
 {
   int value = start;
   {
-    int value = start + 5;
+    __attribute__((__unused__)) int value = start + 5;
     {
-       int value = start + 20;
+       __attribute__((__unused__)) int value = start + 20;
     }
     {
        int value = start + 1;
index d4663771ea40b83273594d268b85b244a2e1f843..8c90cf85ebb8aec6beb56862ad473e06338b5c38 100644 (file)
@@ -16,7 +16,7 @@ struct task
 
 int main()
 {
-    auto t = []() -> task
+    __attribute__((__unused__)) auto t = []() -> task
     {
         co_return 2;
     }();