aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-02-25 15:54:00 +0000
committerPhilip Herron <herron.philip@googlemail.com>2021-03-01 10:35:07 +0000
commit1c6eaa19077eebebf661fe1d633d03ecdc03cbb2 (patch)
tree1acfdde90c7c361b0df785bde6fa189a88530de4 /gcc/rust/resolve
parentec9ead44a40ee68de7fc39e32a47662c44281deb (diff)
downloadgcc-1c6eaa19077eebebf661fe1d633d03ecdc03cbb2.zip
gcc-1c6eaa19077eebebf661fe1d633d03ecdc03cbb2.tar.gz
gcc-1c6eaa19077eebebf661fe1d633d03ecdc03cbb2.tar.bz2
Add some more error handling to generics
Check for wrong number of arguments and fix crash with invalid Type specified as generic argument.
Diffstat (limited to 'gcc/rust/resolve')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-type.h10
-rw-r--r--gcc/rust/resolve/rust-ast-resolve.cc2
2 files changed, 8 insertions, 4 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h b/gcc/rust/resolve/rust-ast-resolve-type.h
index 24090a0..9267e3b 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.h
+++ b/gcc/rust/resolve/rust-ast-resolve-type.h
@@ -112,9 +112,13 @@ public:
{
resolved_node = ResolveTypePath::go (path, parent);
ok = resolved_node != UNKNOWN_NODEID;
- resolver->insert_resolved_type (path.get_node_id (), resolved_node);
- resolver->insert_new_definition (path.get_node_id (),
- Definition{path.get_node_id (), parent});
+ if (ok)
+ {
+ resolver->insert_resolved_type (path.get_node_id (), resolved_node);
+ resolver->insert_new_definition (path.get_node_id (),
+ Definition{path.get_node_id (),
+ parent});
+ }
}
void visit (AST::ArrayType &type)
diff --git a/gcc/rust/resolve/rust-ast-resolve.cc b/gcc/rust/resolve/rust-ast-resolve.cc
index 6bc356a..04fdad7 100644
--- a/gcc/rust/resolve/rust-ast-resolve.cc
+++ b/gcc/rust/resolve/rust-ast-resolve.cc
@@ -462,7 +462,7 @@ ResolvePath::resolve_path (AST::PathInExpression *expr)
else
{
rust_error_at (expr->get_locus (), "unknown path %s",
- expr->as_string ().c_str (), path_buf.c_str ());
+ expr->as_string ().c_str ());
}
}