escape: Analyze function values and conversions.
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 30 Apr 2015 17:44:10 +0000 (17:44 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 30 Apr 2015 17:44:10 +0000 (17:44 +0000)
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

gcc/go/gofrontend/escape.cc

index 80f6ef6dd8353d88afe8e70add4cb30855c1d045..0d8739818ddaea4024a7fb0b80b6565f3997ef47 100644 (file)
@@ -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;