go/internal/gccgoimporter: fix updating of "forward declared" types
The existing code uses a type map which associates a type number with a type; references to existing types are expressed via the type number in the export data. Before this CL, type map entries were set when a type was read in completely, which meant that recursive references to types (i.e., type map entries) that were in the middle of construction (i.e., where the type map was not yet updated) would lead to nil types. Such cycles are usually created via defined types which introduce a types.Named entry into the type map before the underlying type is parsed; in this case the code worked. In case of type aliases, no such "forwarder" exists and type cycles lead to nil types. This CL fixes the problem by a) updating the type map as soon as a type becomes available but before the type's components are parsed; b) keeping track of a list of type map entries that may need to be updated together (because of aliases that may all refer to the same type); and c) adding (redundant) markers to the type map to detect algorithmic errors. Also: - distinguish between parseInt and parseInt64 - added more test cases Fixes #27856. Change-Id: Iba701439ea3231aa435b7b80ea2d419db2af3be1 Reviewed-on: https://go-review.googlesource.com/137857 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Showing
This diff is collapsed.
Please register or sign in to comment