From 2c6cb7e543ffa19b80ab9daf78bb1b9af8061c05 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Wed, 20 May 2020 17:54:47 +0100 Subject: Add the referenced function to the CallExpr when resolved --- gcc/rust/analysis/rust-type-resolution.cc | 2 ++ gcc/rust/ast/rust-expr.h | 3 +++ 2 files changed, 5 insertions(+) (limited to 'gcc') diff --git a/gcc/rust/analysis/rust-type-resolution.cc b/gcc/rust/analysis/rust-type-resolution.cc index 0045420..48ea699 100644 --- a/gcc/rust/analysis/rust-type-resolution.cc +++ b/gcc/rust/analysis/rust-type-resolution.cc @@ -439,11 +439,13 @@ TypeResolution::visit (AST::EnumExprFieldless &expr) void TypeResolution::visit (AST::CallExpr &expr) { + // this look up should probably be moved to name resolution auto fndecl = lookupFndecl (expr.function.get ()); if (fndecl == NULL) return; typeBuffer.push_back (fndecl->return_type.get ()); + expr.fndeclRef = fndecl; auto before = typeBuffer.size (); for (auto &item : expr.params) diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index e0f9536..827ca0d 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -23,6 +23,7 @@ class Statement;*/ // decls no longer required as definitions moved to rust-ast. // Decl as definition moved to rust-ast.h class ExprWithoutBlock; +class Function; // AST node for an expression with an accompanying block - abstract class ExprWithBlock : public Expr @@ -2534,6 +2535,8 @@ public: Location locus; + Function *fndeclRef; + /*~CallExpr() { delete function; }*/ -- cgit v1.1