From: Ian Lance Taylor Date: Thu, 30 Apr 2015 17:44:10 +0000 (+0000) Subject: escape: Analyze function values and conversions. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ae9af49bd4d4f247eb5a1d179e207da899d101a6;p=gcc.git escape: Analyze function values and conversions. The analysis for variables defined as function literals did not properly analyze the underlying function literal when it was converted to a function type. Also, when analyzing composite literals with function literals as arguments, the connection between the composite literal and the function literal was ignored. From-SVN: r222642 --- diff --git a/gcc/go/gofrontend/escape.cc b/gcc/go/gofrontend/escape.cc index 80f6ef6dd83..0d8739818dd 100644 --- a/gcc/go/gofrontend/escape.cc +++ b/gcc/go/gofrontend/escape.cc @@ -906,6 +906,8 @@ Build_connection_graphs::handle_composite_literal(Named_object* object, continue; else if ((*p)->call_expression() != NULL) this->handle_call(object, *p); + else if ((*p)->func_expression() != NULL) + composite_args.push_back((*p)->func_expression()->named_object()); else if ((*p)->is_composite_literal() || (*p)->heap_expression() != NULL) this->handle_composite_literal(object, *p); @@ -949,21 +951,24 @@ Build_connection_graphs::variable(Named_object* var) p != defs->end(); ++p) { - if (p->val == NULL) + Expression* def = p->val; + if (def == NULL) continue; - if (p->val->func_expression() != NULL) + if (def->conversion_expression() != NULL) + def = def->conversion_expression()->expr(); + if (def->func_expression() != NULL) { // VAR is being defined as a function object. - Named_object* fn = p->val->func_expression()->named_object(); + Named_object* fn = def->func_expression()->named_object(); Node* fn_node = this->gogo_->add_connection_node(fn); var_node->add_edge(fn_node); } - else if(p->val->is_composite_literal() - || p->val->heap_expression() != NULL) - this->handle_composite_literal(var, p->val); + else if(def->is_composite_literal() + || def->heap_expression() != NULL) + this->handle_composite_literal(var, def); - Named_object* ref = this->resolve_var_reference(p->val); + Named_object* ref = this->resolve_var_reference(def); if (ref == NULL) continue;