aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-12-23 09:43:35 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-12-23 09:43:35 +0000
commit96bea935c08ab0773b02cdeed7a2c066744fe861 (patch)
tree80e8ff4789acbb8c304cc164ccfae9dd7cdec9a7 /gcc/cp
parent3bdc221879a222778f65d912da99779ebf3c484d (diff)
downloadgcc-96bea935c08ab0773b02cdeed7a2c066744fe861.zip
gcc-96bea935c08ab0773b02cdeed7a2c066744fe861.tar.gz
gcc-96bea935c08ab0773b02cdeed7a2c066744fe861.tar.bz2
[C++] Fix ICE for binding lax vector conversions to references (PR 93014)
This test: typedef unsigned int v4si __attribute__ ((vector_size(16))); typedef unsigned char v16qi __attribute__ ((vector_size(16))); extern v16qi x; v4si &y = x; ICEs with: a.c:4:11: internal compiler error: in convert_like_real, at cp/call.c:7670 This started with r260780, which had the effect of making lvalue_kind look through VIEW_CONVERT_EXPR in all cases, not just for location wrappers. This also means that: typedef unsigned int v4si __attribute__ ((vector_size(16))); typedef unsigned char v16qi __attribute__ ((vector_size(16))); extern v16qi x; v4si &y = reinterpret_cast<v4si>(x); is now valid despite the result of the cast being an rvalue. The patch attempts to fix that by calling rvalue on the input to the conversion, so that the tree looks the same as for: extern v16qi x; v4si &y = (v4si)x; which is already handled correctly. 2019-12-23 Richard Sandiford <richard.sandiford@arm.com> gcc/cp/ * cvt.c (ocp_convert): Apply rvalue to the source of vector conversions. * typeck.c (build_reinterpret_cast_1): Likewise. gcc/testsuite/ * g++.dg/ext/vector39.C: New test. From-SVN: r279716
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/cvt.c4
-rw-r--r--gcc/cp/typeck.c2
3 files changed, 9 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b047dbf..720c3ee 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2019-12-23 Richard Sandiford <richard.sandiford@arm.com>
+
+ * cvt.c (ocp_convert): Apply rvalue to the source of vector
+ conversions.
+ * typeck.c (build_reinterpret_cast_1): Likewise.
+
2019-12-19 Marek Polacek <polacek@redhat.com>
PR c++/92745 - bogus error when initializing array of vectors.
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index e922e4d..9e29225 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -744,7 +744,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags,
else if (TREE_CODE (type) == COMPLEX_TYPE)
return convert_to_complex_maybe_fold (type, e, dofold);
else if (VECTOR_TYPE_P (type))
- return convert_to_vector (type, e);
+ return convert_to_vector (type, rvalue (e));
else if (TREE_CODE (e) == TARGET_EXPR)
{
/* Don't build a NOP_EXPR of class type. Instead, change the
@@ -881,7 +881,7 @@ ocp_convert (tree type, tree expr, int convtype, int flags,
in_vtype, type);
return error_mark_node;
}
- return convert_to_vector (type, e);
+ return convert_to_vector (type, rvalue (e));
}
if (code == REAL_TYPE || code == COMPLEX_TYPE)
{
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 41ef896..d2f4a00 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -7858,7 +7858,7 @@ build_reinterpret_cast_1 (location_t loc, tree type, tree expr,
return build_nop_reinterpret (type, expr);
}
else if (gnu_vector_type_p (type))
- return convert_to_vector (type, expr);
+ return convert_to_vector (type, rvalue (expr));
else if (gnu_vector_type_p (intype)
&& INTEGRAL_OR_ENUMERATION_TYPE_P (type))
return convert_to_integer_nofold (type, expr);