compiler: resolve importing ambiguity for more complex function calls
Tweak the exporter for inlinable function bodies to work around a
problem with importing of function calls whose function expressions
are not simple function names. In the bug in question, the function
body exporter was writing out a function call of the form
(*(*FuncTyp)(var))(arg)
which produced an export data representation of
*$convert(<type 5>, var)(x)
which is hard to parse unambiguously. Fix: change the export data
emitter to introduce parens around the function expression for more
complex calls.
Testcase for this bug is in CL 197217.
Fixes golang/go#34503.
Change-Id: I54bb01b261c54770751fb150d54aa64765b94f09
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/197122
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/go/expressions.cc b/go/expressions.cc
index 7d8963e..a72ba24 100644
--- a/go/expressions.cc
+++ b/go/expressions.cc
@@ -12373,7 +12373,12 @@
void
Call_expression::do_export(Export_function_body* efb) const
{
+ bool simple_call = (this->fn_->func_expression() != NULL);
+ if (!simple_call)
+ efb->write_c_string("(");
this->fn_->export_expression(efb);
+ if (!simple_call)
+ efb->write_c_string(")");
this->export_arguments(efb);
}