]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: Fix match-expression code-gen
authorPhilip Herron <herron.philip@googlemail.com>
Mon, 4 Sep 2023 14:28:46 +0000 (15:28 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:04:32 +0000 (19:04 +0100)
commit3afb921cdaeea68ae11096844fefaf743f64db4b
tree2ea3199170f0d3fc17b56b0b38dd9838bb00ef1d
parent83feca39ba06e865ee4588e607a27e498944f62d
gccrs: Fix match-expression code-gen

We were massing the match scruitinee expression as a way to access the
result of the expression. This is wrong and needs to be stored in a
temporary otherwise it will cause the code to be regnerated for each time
it is used. This is not an issue in the case where the expression is only
used once.

Fixes #1895

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::visit): use a temp for the value

gcc/testsuite/ChangeLog:

* rust/execute/torture/iter1.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/backend/rust-compile-expr.cc
gcc/testsuite/rust/execute/torture/iter1.rs [new file with mode: 0644]