diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-family/c-pretty-print.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr95580.c | 16 |
2 files changed, 19 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)); diff --git a/gcc/testsuite/gcc.dg/pr95580.c b/gcc/testsuite/gcc.dg/pr95580.c new file mode 100644 index 0000000..330a313 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr95580.c @@ -0,0 +1,16 @@ +/* PR c/95580 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -W -fno-tree-dce" } */ + +void bar (void); + +void +foo (int x) +{ + if (x == 0) + { + void *p = __builtin_malloc (4); + ((char *)p)[1] ^= 1; /* { dg-warning "may be used uninitialized" } */ + } + bar (); +} |