c: Allow comparison of pointers to complete and incomplete types for C11 [PR95630]
authorJoseph Myers <joseph@codesourcery.com>
Mon, 23 Nov 2020 23:28:58 +0000 (23:28 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Mon, 23 Nov 2020 23:28:58 +0000 (23:28 +0000)
commited431431e069b59a1cfdd877134873248d8c93a6
treec5e49f7264198cab2d44f1c950e37b9798542820
parentf38a33a2745cf9f5ce1d71162185fe39fa5f3701
c: Allow comparison of pointers to complete and incomplete types for C11 [PR95630]

As noted in bug 95630, C11 removed a restriction in C99 on comparing
pointers to compatible complete and incomplete types (this was one of
the changes in N1439, which was largely a terminological change to
make incomplete types a subset of object types rather than a different
kind of type).  Implement that change by using pedwarn_c99 with
OPT_Wpedantic for this diagnostic.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c/
2020-11-23  Joseph Myers  <joseph@codesourcery.com>

PR c/95630
* c-typeck.c (build_binary_op): Use pedwarn_c99 with OPT_Wpedantic
for comparisons of complete and incomplete pointers.

gcc/testsuite/
2020-11-23  Joseph Myers  <joseph@codesourcery.com>

PR c/95630
* gcc.dg/c11-compare-incomplete-1.c,
gcc.dg/c11-compare-incomplete-2.c,
gcc.dg/c99-compare-incomplete-1.c,
gcc.dg/c99-compare-incomplete-2.c: New tests.
gcc/c/c-typeck.c
gcc/testsuite/gcc.dg/c11-compare-incomplete-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c11-compare-incomplete-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c99-compare-incomplete-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c99-compare-incomplete-2.c [new file with mode: 0644]