This patch to the Go frontend changes set_placeholder_struct_type to use build_variant_type_copy rather than build_distinct_type_copy. This is for PR 86343, which noted that the DECL_CONTEXT of the fields in the copy were pointing to the wrong type. Using build_variant_type_copy puts the types in right relationship for the DECL_CONTEXT setting. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline.
Ian 2018-06-28 Ian Lance Taylor <i...@golang.org> PR go/86343 * go-gcc.cc (Gcc_backend::set_placeholder_struct_type): Call build_variant_type_copy rather than build_distinct_type_copy.
Index: go-gcc.cc =================================================================== --- go-gcc.cc (revision 262150) +++ go-gcc.cc (working copy) @@ -1100,7 +1100,7 @@ Gcc_backend::set_placeholder_struct_type if (TYPE_NAME(t) != NULL_TREE) { // Build the data structure gcc wants to see for a typedef. - tree copy = build_distinct_type_copy(t); + tree copy = build_variant_type_copy(t); TYPE_NAME(copy) = NULL_TREE; DECL_ORIGINAL_TYPE(TYPE_NAME(t)) = copy; }