d: Fix error: aggregate value used where floating point was expected
commit329bef49da30158d30fed1106002bb71674776bd
authorIain Buclaw <ibuclaw@gdcproject.org>
Wed, 29 Jun 2022 19:52:39 +0000 (29 21:52 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Wed, 29 Jun 2022 19:56:28 +0000 (29 21:56 +0200)
treecc2447cb58fa019894a7af0dfc678cd1333b068e
parent49d508065bdd36fb1a9b6aad9666b1edb5e06474
d: Fix error: aggregate value used where floating point was expected

Casting from vector to static array is permitted, and the frontend
generates a reinterpret cast, but casting back the other way resulted in
an error.  This has been fixed to be properly handled in the code
generation pass of VectorExp, and the conversion for lvalue and rvalue
handling done in convert_expr and convert_for_rvalue respectively.

PR d/106139

gcc/d/ChangeLog:

* d-convert.cc (convert_expr): Handle casting from array to vector.
(convert_for_rvalue): Rewrite vector to array casts of the same
element type into a constructor.
(convert_for_assignment): Return calling convert_for_rvalue.
* expr.cc (ExprVisitor::visit (VectorExp *)): Handle generating a
vector expression from a static array.
* toir.cc (IRVisitor::visit (ReturnStatement *)): Call
convert_for_rvalue on return value.

gcc/testsuite/ChangeLog:

* gdc.dg/pr106139a.d: New test.
* gdc.dg/pr106139b.d: New test.
* gdc.dg/pr106139c.d: New test.
* gdc.dg/pr106139d.d: New test.
gcc/d/d-convert.cc
gcc/d/expr.cc
gcc/d/toir.cc
gcc/testsuite/gdc.dg/pr106139a.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/pr106139b.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/pr106139c.d [new file with mode: 0644]
gcc/testsuite/gdc.dg/pr106139d.d [new file with mode: 0644]