]> git.ipfire.org Git - thirdparty/gcc.git/commit
compiler: traverse func subexprs when creating func descriptors
authorIan Lance Taylor <iant@golang.org>
Thu, 11 Nov 2021 02:15:12 +0000 (18:15 -0800)
committerIan Lance Taylor <iant@golang.org>
Thu, 11 Nov 2021 20:21:56 +0000 (12:21 -0800)
commit7846156274db4c58317871c7d5e049e6f2b0ca10
treee3a5bf4f89dd612ffcb61e7277d2956cdc9ef830
parent083fd73202fb7387c16b6c9beab9841939a62acb
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 https://golang.org/issue/49512

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/363274
gcc/go/gofrontend/MERGE
gcc/go/gofrontend/expressions.cc
gcc/go/gofrontend/expressions.h
gcc/go/gofrontend/gogo.cc