Hi Marek.
> On Thu, Aug 17, 2023 at 05:37:03PM +0200, Jose E. Marchesi via Gcc-patches > wrote: >> >> > On Thu, 17 Aug 2023, Jose E. Marchesi via Gcc-patches wrote: >> > >> >> +@opindex Wcompare-distinct-pointer-types >> >> +@item -Wcompare-distinct-pointer-types >> > >> > This @item should say @r{(C and Objective-C only)}, since the option isn't >> > implemented for C++. OK with that change. >> >> Pushed with that change. >> Thanks for the prompt review! > > I see the following failures: > > FAIL: gcc.c-torture/compile/pr106537-1.c -Os (test for warnings, line 28) > FAIL: gcc.c-torture/compile/pr106537-1.c -Os (test for warnings, line 30) > FAIL: gcc.c-torture/compile/pr106537-1.c -O2 -flto > -fno-use-linker-plugin -flto-partition=none (test for warnings, line > 28) > FAIL: gcc.c-torture/compile/pr106537-1.c -O2 -flto > -fno-use-linker-plugin -flto-partition=none (test for warnings, line > 30) > FAIL: gcc.c-torture/compile/pr106537-1.c -O2 -flto -fuse-linker-plugin > -fno-fat-lto-objects (test for warnings, line 28) > FAIL: gcc.c-torture/compile/pr106537-1.c -O2 -flto -fuse-linker-plugin > -fno-fat-lto-objects (test for warnings, line 30) > FAIL: gcc.c-torture/compile/pr106537-2.c -O0 (test for warnings, line 26) > FAIL: gcc.c-torture/compile/pr106537-2.c -O0 (test for warnings, line 28) > FAIL: gcc.c-torture/compile/pr106537-2.c -O1 (test for warnings, line 26) > FAIL: gcc.c-torture/compile/pr106537-2.c -O1 (test for warnings, line 28) > FAIL: gcc.c-torture/compile/pr106537-2.c -O2 (test for warnings, line 26) > FAIL: gcc.c-torture/compile/pr106537-2.c -O2 (test for warnings, line 28) > FAIL: gcc.c-torture/compile/pr106537-2.c -O3 -g (test for warnings, line > 26) > FAIL: gcc.c-torture/compile/pr106537-2.c -O3 -g (test for warnings, line > 28) > FAIL: gcc.c-torture/compile/pr106537-2.c -Os (test for warnings, line 26) > FAIL: gcc.c-torture/compile/pr106537-2.c -Os (test for warnings, line 28) > FAIL: gcc.c-torture/compile/pr106537-2.c -O2 -flto > -fno-use-linker-plugin -flto-partition=none (test for warnings, line > 26) > FAIL: gcc.c-torture/compile/pr106537-2.c -O2 -flto > -fno-use-linker-plugin -flto-partition=none (test for warnings, line > 28) > FAIL: gcc.c-torture/compile/pr106537-2.c -O2 -flto -fuse-linker-plugin > -fno-fat-lto-objects (test for warnings, line 26) > FAIL: gcc.c-torture/compile/pr106537-2.c -O2 -flto -fuse-linker-plugin > -fno-fat-lto-objects (test for warnings, line 28) > > The problem is that for ==/!=, when one of the types is void*, > build_binary_op goes to the branch attempting to warn about > comparing void* with a function pointer, and never gets to the > -Wcompare-distinct-pointer-types warning. Oof I wonder what happened with my regtesting. I just pushed the patch below as obvious, which adjusts the tests to conform to GCC's behavior of not emitting that pedwarn for equality/inequality of void pointers with non-function pointers. Sorry about this. And thanks for reporting. >From 721f7e2c4e5eed645593258624dd91e6c39f3bd2 Mon Sep 17 00:00:00 2001 From: "Jose E. Marchesi" <jose.march...@oracle.com> Date: Thu, 24 Aug 2023 17:10:52 +0200 Subject: [PATCH] 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. --- gcc/testsuite/gcc.c-torture/compile/pr106537-1.c | 6 ++++-- gcc/testsuite/gcc.c-torture/compile/pr106537-2.c | 6 ++++-- 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 3f3b06577d5..b67b6090dc3 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 6876adf3aab..d4223c25c94 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; -- 2.30.2