aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-06-09 08:39:36 +0200
committerJakub Jelinek <jakub@redhat.com>2020-06-09 08:39:36 +0200
commitd6dbb71e468d0db561cc9eca99eeaca1efb81c11 (patch)
tree2293a295ea3c2d2985db643e2eecf968927de0ba /gcc/c-family
parent653ab081391e9e7e38b304f3234323c93693d40c (diff)
downloadgcc-d6dbb71e468d0db561cc9eca99eeaca1efb81c11.zip
gcc-d6dbb71e468d0db561cc9eca99eeaca1efb81c11.tar.gz
gcc-d6dbb71e468d0db561cc9eca99eeaca1efb81c11.tar.bz2
c-family: Fix up MEM_REF printing [PR95580]
The C FE in the MEM_REF printing ICEs if the type of the first argument (which due to useless pointer conversions can be an arbitrary type) is a pointer to an incomplete type. The code just wants to avoid printing a cast if it is a pointer to single byte elements. 2020-06-09 Jakub Jelinek <jakub@redhat.com> PR c/95580 * c-pretty-print.c (c_pretty_printer::unary_expression): Handle the case when MEM_REF's first argument has type pointer to incomplete type. * gcc.dg/pr95580.c: New test.
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-pretty-print.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c
index 71baf5e..ec0bafe 100644
--- a/gcc/c-family/c-pretty-print.c
+++ b/gcc/c-family/c-pretty-print.c
@@ -1789,8 +1789,9 @@ c_pretty_printer::unary_expression (tree e)
if (!integer_zerop (TREE_OPERAND (e, 1)))
{
pp_c_left_paren (this);
- if (!integer_onep (TYPE_SIZE_UNIT
- (TREE_TYPE (TREE_TYPE (TREE_OPERAND (e, 0))))))
+ tree type = TREE_TYPE (TREE_TYPE (TREE_OPERAND (e, 0)));
+ if (TYPE_SIZE_UNIT (type) == NULL_TREE
+ || !integer_onep (TYPE_SIZE_UNIT (type)))
pp_c_type_cast (this, ptr_type_node);
}
pp_c_cast_expression (this, TREE_OPERAND (e, 0));