c: Fix for some variably modified types not being recognized [PR114831]
commit9f1798c1a93257526196a3c19828e40fb28ac551
authorMartin Uecker <uecker@tugraz.at>
Sat, 18 May 2024 12:40:02 +0000 (18 14:40 +0200)
committerMartin Uecker <uecker@tugraz.at>
Fri, 24 May 2024 15:01:11 +0000 (24 17:01 +0200)
treec3d3199b8a3f87e7d2797096262200e8131c3a1f
parentdae606a11eb99814e452b49241fa76f7678f53b8
c: Fix for some variably modified types not being recognized [PR114831]

We did not evaluate expressions with variably modified types correctly
in typeof and did not produce warnings when jumping over declarations
using typeof.  After addressof or array-to-pointer decay we construct
new pointer types that have to be marked variably modified if the pointer
target is variably modified.

2024-05-18 Martin Uecker  <uecker@tugraz.at>

PR c/114831
gcc/c/
* c-typeck.cc (array_to_pointer_conversion, build_unary_op):
Propagate flag to pointer target.

gcc/testsuite/
* gcc.dg/pr114831-1.c: New test.
* gcc.dg/pr114831-2.c: New test.
* gcc.dg/gnu23-varmod-1.c: New test.
* gcc.dg/gnu23-varmod-2.c: New test.
gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/gnu23-varmod-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gnu23-varmod-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr114831-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr114831-2.c [new file with mode: 0644]