On 1/7/21 2:37 PM, Jakub Jelinek wrote:
On Thu, Jan 07, 2021 at 02:29:50PM -0700, Martin Sebor via Gcc-patches wrote:
--- a/gcc/c-family/c-pretty-print.c
+++ b/gcc/c-family/c-pretty-print.c
@@ -1844,22 +1844,25 @@ print_mem_ref (c_pretty_printer *pp, tree e)
}
}
- const tree access_type = TREE_TYPE (e);
+ tree access_type = TREE_TYPE (e);
+ if (TREE_CODE (access_type) == ARRAY_TYPE)
+ access_type = TREE_TYPE (access_type);
tree arg_type = TREE_TYPE (TREE_TYPE (arg));
if (TREE_CODE (arg_type) == ARRAY_TYPE)
arg_type = TREE_TYPE (arg_type);
The array types can be multidimensional, are you sure you don't want
to use strip_array_types instead?
Pretty sure.
access_type is used to figure out the element index and residual
byte offset into the argument, so that needs the size of the array.
Both access_type and arg_type are then checked for compatibility,
to decide if the type of the access needs to be included as a cast.
So there again I think the outer array bounds need to be preserved.
There are a few simple tests involving multidimensional VLAs but
a more involved example I just tried triggers another ICE, this
time in gimple_canonical_types_compatible_p. Apparently
the default invocation of the function doesn't like mixed arrays
and scalars. So clearly there's a whole bounty of ICEs here and
more to do.
Martin