Debian Codegraph @

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

raw
1 /* { dg-do compile } */
2 /* { dg-options "-Wcompare-distinct-pointer-types" } */
3
4 typedef __INT32_TYPE__ __u32;
5
6 struct xdp_md
7 {
8 char *data;
9 char *data_meta;
10 };
11
12 int xdp_context (struct xdp_md *xdp)
13 {
14 void *data = (void *)(__INTPTR_TYPE__)xdp->data;
15 __u32 *metadata = (void *)(__INTPTR_TYPE__)xdp->data_meta;
16 __u32 ret;
17
18 if (metadata + 1 > data) /* { dg-warning "comparison of distinct pointer types" } */
19 return 1;
20 if (metadata + 1 >= data) /* { dg-warning "comparison of distinct pointer types" } */
21 return 2;
22 if (metadata + 1 < data) /* { dg-warning "comparison of distinct pointer types" } */
23 return 3;
24 if (metadata + 1 <= data) /* { dg-warning "comparison of distinct pointer types" } */
25 return 4;
26 /* Note that it is ok to check for equality or inequality betewen void
27 pointers and any other non-function pointers. */
28 if ((int*) (metadata + 1) == (long*) data) /* { dg-warning "comparison of distinct pointer types" } */
29 return 5;
30 if ((int*) metadata + 1 != (long*) data) /* { dg-warning "comparison of distinct pointer types" } */
31 return 5;
32
33 return 1;
34 }