aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose E. Marchesi <jose.marchesi@oracle.com>2023-08-24 17:10:52 +0200
committerJose E. Marchesi <jose.marchesi@oracle.com>2023-08-24 17:14:01 +0200
commit721f7e2c4e5eed645593258624dd91e6c39f3bd2 (patch)
tree9990880499ff3bfef19cc8513c735c418cbc8794
parentbbdc0e0d0042ae16aa4d09ceb52c71e746d9139d (diff)
downloadgcc-721f7e2c4e5eed645593258624dd91e6c39f3bd2.zip
gcc-721f7e2c4e5eed645593258624dd91e6c39f3bd2.tar.gz
gcc-721f7e2c4e5eed645593258624dd91e6c39f3bd2.tar.bz2
Fix tests for PR 106537.
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.
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr106537-1.c6
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr106537-2.c6
2 files changed, 8 insertions, 4 deletions
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr106537-1.c b/gcc/testsuite/gcc.c-torture/compile/pr106537-1.c
index 3f3b065..b67b609 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr106537-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr106537-1.c
@@ -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;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr106537-2.c b/gcc/testsuite/gcc.c-torture/compile/pr106537-2.c
index 6876adf..d4223c2 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr106537-2.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr106537-2.c
@@ -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;