If you apply Index: gcc/tree.c =================================================================== --- gcc/tree.c (revision 262215) +++ gcc/tree.c (working copy) @@ -13878,6 +13878,16 @@ verify_type (const_tree t) debug_tree (fld); error_found = true; } + if (DECL_CONTEXT (fld) != TYPE_MAIN_VARIANT (t) + /* class scope enums have their CONST_DECLs in the class + TYPE_FIELDS chain in C++. */ + && (TREE_CODE (fld) != CONST_DECL + || TREE_CODE (DECL_CONTEXT (fld)) != ENUMERAL_TYPE)) + { + error ("Wrong DECL_CONTEXT in TYPE_FIELDS list"); + debug_tree (fld); + error_found = true; + } } } else if (TREE_CODE (t) == INTEGER_TYPE then you'll hit an ICE building libgo/go/errors/errors.go on x86_64-linux: go1: error: Wrong DECL_CONTEXT in TYPE_FIELDS list <field_decl 0x7f9e5055b098 _type type <record_type 0x7f9e50557d20 _type BLK size <integer_cst 0x7f9e505426f0 constant 576> unit-size <integer_cst 0x7f9e50542768 constant 72> ... go1: internal compiler error: verify_type failed 0xf71582 verify_type(tree_node const*) /space/rguenther/src/svn/trunk/gcc/tree.c:13982 0x98fa94 gen_type_die_with_usage /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:25389 where (gdb) p (void)debug_tree (type) <record_type 0x7ffff67d67e0 BLK size <integer_cst 0x7ffff67be8e8 type <integer_type 0x7ffff67b60a8 bitsizetype> constant 768> unit-size <integer_cst 0x7ffff67be870 type <integer_type 0x7ffff67b6000 sizetype> constant 96> align:64 warn_if_not_align:0 symtab:0 alias-set -1 structural-equality fields <field_decl 0x7ffff67d7098 _type type <record_type 0x7ffff67d3d20 _type BLK size <integer_cst 0x7ffff67be6f0 constant 576> unit-size <integer_cst 0x7ffff67be768 constant 72> align:64 warn_if_not_align:0 symtab:0 alias-set -1 structural-equality fields <field_decl 0x7ffff67d4be0 size> pointer_to_this <pointer_type 0x7ffff67d9c78>> BLK <built-in>:0:0 size <integer_cst 0x7ffff67be6f0 576> unit-size <integer_cst 0x7ffff67be768 72> align:64 warn_if_not_align:0 offset_align 128 offset <integer_cst 0x7ffff67a2c18 constant 0> bit-offset <integer_cst 0x7ffff67a2c60 constant 0> context <record_type 0x7ffff67d65e8 StructType> and (gdb) p ((tree)0x7ffff67d65e8)->type_common.main_variant $3 = (tree) 0x7ffff67d65e8 (gdb) p ((tree)0x7ffff67d67e0)->type_common.main_variant $4 = (tree) 0x7ffff67d67e0 the type looks like struct { struct _type; struct { struct * __values; int __count; int __capacity; } fields; } but otherwise is anonymous so it's hard to tell where it originates. I'm hoping to push this verification to trunk but it fails to bootstrap with GO. Basically TYPE_FIELDS (and thus FIELD_DECL) sharing is only valid between a types variants (thus types sharing the same TYPE_MAIN_VARIANT) where they are actually expected to be shared.
Author: ian Date: Thu Jun 28 17:46:36 2018 New Revision: 262225 URL: https://gcc.gnu.org/viewcvs?rev=262225&root=gcc&view=rev Log: PR go/86343 * go-gcc.cc (Gcc_backend::set_placeholder_struct_type): Call build_variant_type_copy rather than build_distinct_type_copy. Modified: trunk/gcc/go/ChangeLog trunk/gcc/go/go-gcc.cc
Should be fixed. Sorry for the problem.
Author: ian Date: Wed Jan 9 23:38:55 2019 New Revision: 267789 URL: https://gcc.gnu.org/viewcvs?rev=267789&root=gcc&view=rev Log: PR go/86343 * go-gcc.cc (Gcc_backend::set_placeholder_struct_type): Go back to build_distinct_type_copy, but copy the fields so that they have the right DECL_CONTEXT. Modified: trunk/gcc/go/ChangeLog trunk/gcc/go/go-gcc.cc