[C++] Fix ICE for binding lax vector conversions to references (PR 93014)
authorRichard Sandiford <richard.sandiford@arm.com>
Mon, 23 Dec 2019 09:43:35 +0000 (09:43 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Mon, 23 Dec 2019 09:43:35 +0000 (09:43 +0000)
commit96bea935c08ab0773b02cdeed7a2c066744fe861
tree80e8ff4789acbb8c304cc164ccfae9dd7cdec9a7
parent3bdc221879a222778f65d912da99779ebf3c484d
[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
gcc/cp/ChangeLog
gcc/cp/cvt.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/vector39.C [new file with mode: 0644]