re PR c++/90969 (ICE: tree check: expected array_type, have vector_type in array_ref_...
authorJakub Jelinek <jakub@redhat.com>
Tue, 25 Jun 2019 14:05:13 +0000 (16:05 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 25 Jun 2019 14:05:13 +0000 (16:05 +0200)
PR c++/90969
* constexpr.c (cxx_eval_array_reference): Don't look through VCE from
vector type if lval.

* g++.dg/ext/vector38.C: New test.

From-SVN: r272654

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/vector38.C [new file with mode: 0644]

index 3459ad7718b276175cd337dce1449d3e080af38f..a0f61668559d9b042d761041fb9254060cc16ac7 100644 (file)
@@ -1,3 +1,9 @@
+2019-06-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/90969
+       * constexpr.c (cxx_eval_array_reference): Don't look through VCE from
+       vector type if lval.
+
 2019-06-24  Jan Hubicka  <jh@suse.cz>
 
        * lex.c (cxx_make_type): Set TYPE_CXX_ODR_P.
index 22f4fa0d3511b3285dabc7bf9e844e0c3796520f..a3a36d09d5ef5d08a9fca719598cc146becef7bb 100644 (file)
@@ -2616,7 +2616,8 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, tree t,
                                           non_constant_p, overflow_p);
   if (*non_constant_p)
     return t;
-  if (TREE_CODE (ary) == VIEW_CONVERT_EXPR
+  if (!lval
+      && TREE_CODE (ary) == VIEW_CONVERT_EXPR
       && VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (ary, 0)))
       && TREE_TYPE (t) == TREE_TYPE (TREE_TYPE (TREE_OPERAND (ary, 0))))
     ary = TREE_OPERAND (ary, 0);
index ca27bc3bffd2cc5f0ba1d3c99a8f4855a3f494a5..1270f44fac39ff7a5f257501373097e895a22ef3 100644 (file)
@@ -1,3 +1,8 @@
+2019-06-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/90969
+       * g++.dg/ext/vector38.C: New test.
+
 2019-06-25  Martin Jambor  <mjambor@suse.cz>
 
        PR ipa/90939
diff --git a/gcc/testsuite/g++.dg/ext/vector38.C b/gcc/testsuite/g++.dg/ext/vector38.C
new file mode 100644 (file)
index 0000000..51a0887
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/90969
+// { dg-do compile }
+
+__attribute__ ((__vector_size__ (4))) int v;
+int &a = v[0];