compiler: traverse func subexprs when creating func descriptors

Fix the Create_func_descriptors pass to traverse the subexpressions of
the function in a Call_expression.  There are no subexpressions in the
normal case of calling a function a method directly, but there are
subexpressions when in code like F().M() when F returns an interface type.

Forgetting to traverse the function subexpressions was almost entirely
hidden by the fact that we also created the necessary thunks in
Bound_method_expression::do_flatten and
Interface_field_reference_expression::do_get_backend.  However, when
the thunks were created there, they did not go through the
order_evaluations pass.  This almost always worked, but failed in the
case in which the function being thunked returned multiple results, as
order_evaluations takes the necessary step of moving the
Call_expression into its own statement, and that would not happen when
order_evaluations was not called.  Avoid hiding errors like this by
changing those methods to only lookup the previously created thunk,
rather than creating it if it was not already created.

The test case for this is https://golang.org/cl/363156.

Fixes golang/go#49512

Change-Id: I6b273156f16ed6ed22e600097628a1cb6499de64
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/363274
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 files changed
tree: 54893d0211714fcf3aaa0ac2ff6ac87389b69016
  1. go/
  2. libgo/
  3. .gitignore
  4. AUTHORS
  5. codereview.cfg
  6. CONTRIBUTORS
  7. HACKING
  8. LICENSE
  9. PATENTS
  10. README.md
README.md

A Go frontend

Ian Lance Taylor Last update 15 June 2014

This is a compiler frontend for the Go programming language. The frontend was originally developed at Google, and was released in November 2009. It was originally written by Ian Lance Taylor.

It was originally written for GCC. As of this writing it only supports GCC, but the GCC support has been separated from the rest of the frontend, so supporting another compiler is feasible.

The go subdirectory holds the frontend source code. This is mirrored to the gcc/go subdirectory in the GCC repository.

The libgo subdirectory holds the library source code. This is a copy of the main Go library with various changes appropriate for this compiler. The main Go library is hosted at http://go.googlesource.com/go, in the src directory. The libgo subdirectory is mirrored to the libgo subdirectory in the gcc repository.

Legal Matters

To contribute patches to the files in this directory, please see Contributing to the gccgo frontend.

The master copy of these files is hosted in Gerrit (there is a mirror at Github). Changes to these files require signing a Google contributor license agreement. If you are the copyright holder, you will need to agree to the Google Individual Contributor License Agreement. This agreement can be completed online.

If your organization is the copyright holder, the organization will need to agree to the Google Software Grant and Corporate Contributor License Agreement.

If the copyright holder for your code has already completed the agreement in connection with another Google open source project, it does not need to be completed again.

The authors of these files may be found in the AUTHORS and CONTRIBUTORS files.