]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Address '?:' issues in 'libgomp.oacc-c-c++-common/mode-transitions.c'
authorThomas Schwinge <thomas@codesourcery.com>
Wed, 11 Aug 2021 09:59:19 +0000 (11:59 +0200)
committerThomas Schwinge <thomas@codesourcery.com>
Mon, 16 Aug 2021 10:12:09 +0000 (12:12 +0200)
    [...]/libgomp.oacc-c-c++-common/mode-transitions.c: In function ‘t3’:
    [...]/libgomp.oacc-c-c++-common/mode-transitions.c:127:43: warning: ‘?:’ using integer constants in boolean context, the expression will always evaluate to ‘true’ [-Wint-in-bool-context]
      127 |     assert (arr[i] == ((i % 64) < 32) ? 1 : -1);
          |                                           ^

    [...]/libgomp.oacc-c-c++-common/mode-transitions.c: In function ‘t9’:
    [...]/libgomp.oacc-c-c++-common/mode-transitions.c:359:46: warning: ‘?:’ using integer constants in boolean context, the expression will always evaluate to ‘true’ [-Wint-in-bool-context]
      359 |         assert (arr[i] == ((i % 3) == 0) ? 1 : 2);
          |                                              ^

..., and PR101862 "[C, C++] Potential '?:' diagnostic for always-true
expressions in boolean context".

libgomp/
* testsuite/libgomp.oacc-c-c++-common/mode-transitions.c: Address
'?:' issues.

libgomp/testsuite/libgomp.oacc-c-c++-common/mode-transitions.c

index 6c989abedf5cc4f783da051741496f3fc1f32578..94dc9d0529336a5d99fb6cc6d42554f6a2776777 100644 (file)
@@ -124,7 +124,7 @@ void t3()
     assert (n[i] == 2);
 
   for (i = 0; i < 1024; i++)
-    assert (arr[i] == ((i % 64) < 32) ? 1 : -1);
+    assert (arr[i] == (((i % 64) < 32) ? 1 : -1));
 }
 
 
@@ -356,7 +356,7 @@ void t9()
       }
 
       for (i = 0; i < 1024; i++)
-       assert (arr[i] == ((i % 3) == 0) ? 1 : 2);
+       assert (arr[i] == ((i % 3) == 0 ? 1 : 2));
     }
 }
 
@@ -960,7 +960,7 @@ void t23()
   }
 
   for (i = 0; i < 32; i++)
-    assert (arr[i] == ((i % 2) != 0) ? i + 1 : i + 2);
+    assert (arr[i] == (((i % 2) != 0) ? i + 1 : i + 2));
 }