From b72805798ac456709eef4a761b84dd1c4a5780e6 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 14 Dec 2017 11:13:34 +0000 Subject: [PATCH] re PR middle-end/83415 (ICE during gimplification of assignment to read-only vector) 2017-12-14 Richard Biener PR c/83415 c/ * c-fold.c (c_fully_fold_internal): Treat VIEW_CONVERT_EXPR like REALPART_EXPR for the behavior of whether its operand is an lvalue. * gcc.dg/pr83415.c: New testcase. From-SVN: r255629 --- gcc/c/ChangeLog | 7 +++++++ gcc/c/c-fold.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr83415.c | 12 ++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr83415.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 6516e5d5982..3f5414bc18d 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,10 @@ +2017-12-14 Richard Biener + + PR c/83415 + * c-fold.c (c_fully_fold_internal): Treat VIEW_CONVERT_EXPR + like REALPART_EXPR for the behavior of whether its operand + is an lvalue. + 2017-12-12 Marek Polacek PR c/82679 diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.c index 84ce543be75..49d248df491 100644 --- a/gcc/c/c-fold.c +++ b/gcc/c/c-fold.c @@ -434,6 +434,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, goto unary; case REALPART_EXPR: case IMAGPART_EXPR: + case VIEW_CONVERT_EXPR: op0_lval = lval; /* FALLTHRU */ case INDIRECT_REF: @@ -441,7 +442,6 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, case FLOAT_EXPR: CASE_CONVERT: case ADDR_SPACE_CONVERT_EXPR: - case VIEW_CONVERT_EXPR: case NON_LVALUE_EXPR: case NEGATE_EXPR: case BIT_NOT_EXPR: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 811568e7d2a..2f2d545b0b5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-12-14 Richard Biener + + PR c/83415 + * gcc.dg/pr83415.c: New testcase. + 2017-12-14 Richard Biener PR tree-optimization/83418 diff --git a/gcc/testsuite/gcc.dg/pr83415.c b/gcc/testsuite/gcc.dg/pr83415.c new file mode 100644 index 00000000000..5934c16d97c --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr83415.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +const short __attribute__((vector_size(16))) y = { 0, 1, 2, 3, 4, 5, 6, 7 }; + +int +main (int argc, short *argv[]) +{ + int i = argc; + y[i] = 7 - i; /* { dg-warning "read-only" } */ + return 0; +} -- 2.30.2