aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/analysis
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2020-12-01 16:18:25 +0000
committerPhilip Herron <herron.philip@googlemail.com>2020-12-01 17:50:50 +0000
commit8993741f97ca3426e22a740070b9a413dcb2fe04 (patch)
tree5d7fb01e8c3a3bbb350653fb3f71e7e1584012c2 /gcc/rust/analysis
parent3f491614f6e4e2dea93b534c063c142e8de55bb3 (diff)
downloadgcc-8993741f97ca3426e22a740070b9a413dcb2fe04.zip
gcc-8993741f97ca3426e22a740070b9a413dcb2fe04.tar.gz
gcc-8993741f97ca3426e22a740070b9a413dcb2fe04.tar.bz2
GIMPLE coversions for ArrayIndexExpr and Arrays with values
This compiles the ArrayIndexExpressions and Arrays such as: let x = [1,2,3]; let a = x[0]; Addresses: #55
Diffstat (limited to 'gcc/rust/analysis')
-rw-r--r--gcc/rust/analysis/rust-type-resolution.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/rust/analysis/rust-type-resolution.cc b/gcc/rust/analysis/rust-type-resolution.cc
index 5500faf..541acd0 100644
--- a/gcc/rust/analysis/rust-type-resolution.cc
+++ b/gcc/rust/analysis/rust-type-resolution.cc
@@ -466,7 +466,17 @@ void
TypeResolution::visit (AST::ArrayExpr &expr)
{
auto elements = expr.get_internal_elements ();
+
+ auto before = typeBuffer.size ();
elements->accept_vis (*this);
+ if (typeBuffer.size () <= before)
+ {
+ rust_error_at (expr.get_locus_slow (),
+ "unable to determine type for ArrayExpr");
+ return;
+ }
+
+ expr.set_inferred_type (typeBuffer.back ());
}
void