https://gcc.gnu.org/g:7f27d1f1b94843caed557b83715a94cb5b7deb0d

commit r15-3338-g7f27d1f1b94843caed557b83715a94cb5b7deb0d
Author: Iain Sandoe <i...@sandoe.co.uk>
Date:   Sat Aug 31 12:53:40 2024 +0100

    testsuite, c++, coroutines: Avoid 'unused' warnings [NFC].
    
    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 <i...@sandoe.co.uk>

Diff:
---
 gcc/testsuite/g++.dg/coroutines/coro.h                                | 4 ++--
 gcc/testsuite/g++.dg/coroutines/torture/co-await-04-control-flow.C    | 1 +
 gcc/testsuite/g++.dg/coroutines/torture/co-ret-13-template-2.C        | 2 +-
 gcc/testsuite/g++.dg/coroutines/torture/exceptions-test-01-n4849-a.C  | 1 -
 .../g++.dg/coroutines/torture/local-var-04-hiding-nested-scopes.C     | 4 ++--
 gcc/testsuite/g++.dg/coroutines/torture/pr109867.C                    | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gcc/testsuite/g++.dg/coroutines/coro.h 
b/gcc/testsuite/g++.dg/coroutines/coro.h
index 491177f0cfd5..71c1cd73207d 100644
--- a/gcc/testsuite/g++.dg/coroutines/coro.h
+++ b/gcc/testsuite/g++.dg/coroutines/coro.h
@@ -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
diff --git a/gcc/testsuite/g++.dg/coroutines/torture/co-await-04-control-flow.C 
b/gcc/testsuite/g++.dg/coroutines/torture/co-await-04-control-flow.C
index fd201f904816..32d9c982d4a1 100644
--- a/gcc/testsuite/g++.dg/coroutines/torture/co-await-04-control-flow.C
+++ b/gcc/testsuite/g++.dg/coroutines/torture/co-await-04-control-flow.C
@@ -1,4 +1,5 @@
 //  { dg-do run }
+//  { dg-additional-options "-Wno-unused-label" }
 
 // Check correct operation of await transform.
 
diff --git a/gcc/testsuite/g++.dg/coroutines/torture/co-ret-13-template-2.C 
b/gcc/testsuite/g++.dg/coroutines/torture/co-ret-13-template-2.C
index 9d4a4de8ebe8..8a8d2d6fa5d9 100644
--- a/gcc/testsuite/g++.dg/coroutines/torture/co-ret-13-template-2.C
+++ b/gcc/testsuite/g++.dg/coroutines/torture/co-ret-13-template-2.C
@@ -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;
 }
 
diff --git 
a/gcc/testsuite/g++.dg/coroutines/torture/exceptions-test-01-n4849-a.C 
b/gcc/testsuite/g++.dg/coroutines/torture/exceptions-test-01-n4849-a.C
index 6433b62109fc..c5a0a38b2ca2 100644
--- a/gcc/testsuite/g++.dg/coroutines/torture/exceptions-test-01-n4849-a.C
+++ b/gcc/testsuite/g++.dg/coroutines/torture/exceptions-test-01-n4849-a.C
@@ -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;
 }
diff --git 
a/gcc/testsuite/g++.dg/coroutines/torture/local-var-04-hiding-nested-scopes.C 
b/gcc/testsuite/g++.dg/coroutines/torture/local-var-04-hiding-nested-scopes.C
index 419eb6b64673..04c1ab362d2d 100644
--- 
a/gcc/testsuite/g++.dg/coroutines/torture/local-var-04-hiding-nested-scopes.C
+++ 
b/gcc/testsuite/g++.dg/coroutines/torture/local-var-04-hiding-nested-scopes.C
@@ -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;
diff --git a/gcc/testsuite/g++.dg/coroutines/torture/pr109867.C 
b/gcc/testsuite/g++.dg/coroutines/torture/pr109867.C
index d4663771ea40..8c90cf85ebb8 100644
--- a/gcc/testsuite/g++.dg/coroutines/torture/pr109867.C
+++ b/gcc/testsuite/g++.dg/coroutines/torture/pr109867.C
@@ -16,7 +16,7 @@ struct task
 
 int main()
 {
-    auto t = []() -> task
+    __attribute__((__unused__)) auto t = []() -> task
     {
         co_return 2;
     }();

Reply via email to