aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/expr.cc
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2023-10-29 20:13:14 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2023-10-29 20:13:14 +0100
commitea8ffdcadb388b531adf4772287e7987a82a84b7 (patch)
tree4888963b6cc06c6e65b364ff1cb26bfbf04798d6 /gcc/d/expr.cc
parente773c6c7009bb35fa50da034f3537448fd36c7f0 (diff)
downloadgcc-ea8ffdcadb388b531adf4772287e7987a82a84b7.zip
gcc-ea8ffdcadb388b531adf4772287e7987a82a84b7.tar.gz
gcc-ea8ffdcadb388b531adf4772287e7987a82a84b7.tar.bz2
d: Fix ICE: verify_gimple_failed (conversion of register to a different size in 'view_convert_expr')
Static arrays in D are passed around by value, rather than decaying to a pointer. On x86_64 __builtin_va_list is an exception to this rule, but semantically it's still treated as a static array. This makes certain assignment operations fail due a mismatch in types. As all examples in the test program are rejected by C/C++ front-ends, these are now errors in D too to be consistent. PR d/110712 gcc/d/ChangeLog: * d-codegen.cc (d_build_call): Update call to convert_for_argument. * d-convert.cc (is_valist_parameter_type): New function. (check_valist_conversion): New function. (convert_for_assignment): Update signature. Add check whether assigning va_list is permissible. (convert_for_argument): Likewise. * d-tree.h (convert_for_assignment): Update signature. (convert_for_argument): Likewise. * expr.cc (ExprVisitor::visit (AssignExp *)): Update call to convert_for_assignment. gcc/testsuite/ChangeLog: * gdc.dg/pr110712.d: New test.
Diffstat (limited to 'gcc/d/expr.cc')
-rw-r--r--gcc/d/expr.cc12
1 files changed, 4 insertions, 8 deletions
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index 29f114a..ef4ea60 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -972,8 +972,7 @@ public:
Declaration *decl = e->e1->isVarExp ()->var;
if (decl->storage_class & (STCout | STCref))
{
- tree t2 = convert_for_assignment (build_expr (e->e2),
- e->e2->type, e->e1->type);
+ tree t2 = convert_for_assignment (e->e2, e->e1->type);
tree t1 = build_expr (e->e1);
/* Want reference to lhs, not indirect ref. */
t1 = TREE_OPERAND (t1, 0);
@@ -993,8 +992,7 @@ public:
if (tb1->ty == TY::Tstruct)
{
tree t1 = build_expr (e->e1);
- tree t2 = convert_for_assignment (build_expr (e->e2, false, true),
- e->e2->type, e->e1->type);
+ tree t2 = convert_for_assignment (e->e2, e->e1->type, true);
StructDeclaration *sd = tb1->isTypeStruct ()->sym;
/* Look for struct = 0. */
@@ -1073,8 +1071,7 @@ public:
|| (e->op == EXP::blit || e->e1->type->size () == 0))
{
tree t1 = build_expr (e->e1);
- tree t2 = convert_for_assignment (build_expr (e->e2),
- e->e2->type, e->e1->type);
+ tree t2 = convert_for_assignment (e->e2, e->e1->type);
this->result_ = build_assign (modifycode, t1, t2);
return;
@@ -1088,8 +1085,7 @@ public:
/* Simple assignment. */
tree t1 = build_expr (e->e1);
- tree t2 = convert_for_assignment (build_expr (e->e2),
- e->e2->type, e->e1->type);
+ tree t2 = convert_for_assignment (e->e2, e->e1->type);
this->result_ = build_assign (modifycode, t1, t2);
}