]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix tests for PR 106537.
authorJose E. Marchesi <jose.marchesi@oracle.com>
Thu, 24 Aug 2023 15:10:52 +0000 (17:10 +0200)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Thu, 24 Aug 2023 15:14:01 +0000 (17:14 +0200)
This patch fixes the tests for PR 106537 (support for
-W[no]-compare-distinct-pointer-types) which were expecting the
warning when checking for equality/inequality of void pointers with
non-function pointers.

gcc/testsuite/ChangeLog:

PR c/106537
* gcc.c-torture/compile/pr106537-1.c: Comparing void pointers to
non-function pointers is legit.
* gcc.c-torture/compile/pr106537-2.c: Likewise.

gcc/testsuite/gcc.c-torture/compile/pr106537-1.c
gcc/testsuite/gcc.c-torture/compile/pr106537-2.c

index 3f3b06577d52f4acd06d4cf9e97075898e2b8a47..b67b6090dc3851483e47db622586e7b47c8f86dd 100644 (file)
@@ -25,9 +25,11 @@ int xdp_context (struct xdp_md *xdp)
     return 3;
   if (metadata + 1 <= data) /* { dg-warning "comparison of distinct pointer types" } */
     return 4;
-  if (metadata + 1 == data) /* { dg-warning "comparison of distinct pointer types" } */
+  /* Note that it is ok to check for equality or inequality betewen void
+     pointers and any other non-function pointers.  */
+  if ((int*) (metadata + 1) == (long*) data) /* { dg-warning "comparison of distinct pointer types" } */
     return 5;
-  if (metadata + 1 != data) /* { dg-warning "comparison of distinct pointer types" } */
+  if ((int*) metadata + 1 != (long*) data) /* { dg-warning "comparison of distinct pointer types" } */
     return 5;
 
   return 1;
index 6876adf3aab1090a9a90e454faecbd47609f341a..d4223c25c949903fe06c6b18deb61eee761e7e5e 100644 (file)
@@ -23,9 +23,11 @@ int xdp_context (struct xdp_md *xdp)
     return 3;
   if (metadata + 1 <= data) /* { dg-warning "comparison of distinct pointer types" } */
     return 4;
-  if (metadata + 1 == data) /* { dg-warning "comparison of distinct pointer types" } */
+  /* Note that it is ok to check for equality or inequality betewen void
+     pointers and any other non-function pointers.  */
+  if ((int*) (metadata + 1) == (long*) data) /* { dg-warning "comparison of distinct pointer types" } */
     return 5;
-  if (metadata + 1 != data) /* { dg-warning "comparison of distinct pointer types" } */
+  if ((int*) metadata + 1 != (long*) data) /* { dg-warning "comparison of distinct pointer types" } */
     return 5;
 
   return 1;