re PR middle-end/83415 (ICE during gimplification of assignment to read-only vector)
authorRichard Biener <rguenther@suse.de>
Thu, 14 Dec 2017 11:13:34 +0000 (11:13 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 14 Dec 2017 11:13:34 +0000 (11:13 +0000)
2017-12-14  Richard Biener  <rguenther@suse.de>

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
gcc/c/c-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr83415.c [new file with mode: 0644]

index 6516e5d598251db2bfb4dfefc6504bd192c9129e..3f5414bc18de3153fdd007a2631882629a99d62a 100644 (file)
@@ -1,3 +1,10 @@
+2017-12-14  Richard Biener  <rguenther@suse.de>
+
+       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  <polacek@redhat.com>
 
        PR c/82679
index 84ce543be7593705d53f6c18a1c8eaa8cc4cd0a0..49d248df4919d8911e8bc8023835e5d2d35ae1fa 100644 (file)
@@ -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:
index 811568e7d2a4babd4c65fce1612873870a1a5e0f..2f2d545b0b565e1e13770e3e3a5527f09179497a 100644 (file)
@@ -1,3 +1,8 @@
+2017-12-14  Richard Biener  <rguenther@suse.de>
+
+       PR c/83415
+       * gcc.dg/pr83415.c: New testcase.
+
 2017-12-14  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/83418
diff --git a/gcc/testsuite/gcc.dg/pr83415.c b/gcc/testsuite/gcc.dg/pr83415.c
new file mode 100644 (file)
index 0000000..5934c16
--- /dev/null
@@ -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;
+}