Another case of missed TREE_ADDRESSABLE on vector indexing.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Ok for trunk?

2017-03-02  Richard Biener  <rguent...@suse.de>

        PR c/79756
        * c-common.c (c_common_mark_addressable_vec): Look through
        C_MAYBE_CONST_EXPR.

        * gcc.dg/vector-1.c: New testcase.

Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c     (revision 245833)
+++ gcc/c-family/c-common.c     (working copy)
@@ -6534,6 +6534,8 @@ complete_array_type (tree *ptype, tree i
 void 
 c_common_mark_addressable_vec (tree t)
 {   
+  if (TREE_CODE (t) == C_MAYBE_CONST_EXPR)
+    t = C_MAYBE_CONST_EXPR_EXPR (t);
   while (handled_component_p (t))
     t = TREE_OPERAND (t, 0);
   if (!VAR_P (t)
Index: gcc/testsuite/gcc.dg/vector-1.c
===================================================================
--- gcc/testsuite/gcc.dg/vector-1.c     (nonexistent)
+++ gcc/testsuite/gcc.dg/vector-1.c     (working copy)
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu90" } */
+
+typedef int V __attribute__ ((vector_size(4)));
+void fn1 ()
+{
+  (V){(1,0)}[0] = 0;
+}

Reply via email to