Hi Ian,
> On Tue, Dec 8, 2020 at 2:57 PM Nikhil Benesch <[email protected]>
> wrote:
>>
>> This patch corrects -fdump-go-spec's handling of incomplete types.
>> To my knowledge the issue fixed here has not been previously
>> reported. It was exposed by an in-progress port of gccgo to FreeBSD.
>>
>> Given the following C code
>>
>> struct s_fwd v_fwd;
>> struct s_fwd { };
>>
>> -fdump-go-spec currently produces the following Go code
>>
>> var v_fwd struct {};
>> type s_fwd s_fwd;
>>
>> whereas the correct Go code is:
>>
>> var v_fwd s_fwd;
>> type s_fwd struct {};
>>
>> (Go is considerably more permissive than C with out-of-order
>> declarations, so anywhere an out-of-order declaration is valid in
>> C it is valid in Go.)
>>
>> gcc/:
>> * godump.c (go_format_type): Don't consider whether a type has
>> been seen when determining whether to output a type by name.
>> Consider only the use_type_name parameter.
>> (go_output_typedef): When outputting a typedef, format the
>> declaration's original type, which contains the name of the
>> underlying type rather than the name of the typedef.
>> gcc/testsuite:
>> * gcc.misc-tests/godump-1.c: Add test case.
>
> Thanks. I changed function types to use type names, and committed like so.
This patch badly broke Solaris bootstrap:
runtime_sysinfo.go:623:6: error: invalid recursive type
623 | type ___FILE ___FILE
| ^
runtime_sysinfo.go:7045:6: error: redefinition of ‘_mld_hdr_t’
7045 | type _mld_hdr_t _mld_hdr
| ^
runtime_sysinfo.go:1510:6: note: previous definition of ‘_mld_hdr_t’ was here
1510 | type _mld_hdr_t _mld_hdr
| ^
runtime_sysinfo.go:7070:6: error: redefinition of ‘_upad128_t’
7070 | type _upad128_t struct { _l [4]uint32; }
| ^
runtime_sysinfo.go:7029:6: note: previous definition of ‘_upad128_t’ was here
7029 | type _upad128_t struct {}
| ^
runtime_sysinfo.go:7071:6: error: redefinition of ‘_zone_net_addr_t’
7071 | type _zone_net_addr_t _zone_net_addr
| ^
runtime_sysinfo.go:1079:6: note: previous definition of ‘_zone_net_addr_t’ was
here
1079 | type _zone_net_addr_t _zone_net_addr
| ^
runtime_sysinfo.go:7072:6: error: redefinition of ‘_flow_arp_desc_t’
7072 | type _flow_arp_desc_t _flow_arp_desc_s
| ^
runtime_sysinfo.go:1127:6: note: previous definition of ‘_flow_arp_desc_t’ was
here
1127 | type _flow_arp_desc_t _flow_arp_desc_s
| ^
runtime_sysinfo.go:7073:6: error: redefinition of ‘_flow_l3_desc_t’
7073 | type _flow_l3_desc_t _flow_l3_desc_s
| ^
runtime_sysinfo.go:1130:6: note: previous definition of ‘_flow_l3_desc_t’ was
here
1130 | type _flow_l3_desc_t _flow_l3_desc_s
| ^
runtime_sysinfo.go:7074:6: error: redefinition of ‘_mac_ipaddr_t’
7074 | type _mac_ipaddr_t _mac_ipaddr_s
| ^
runtime_sysinfo.go:1150:6: note: previous definition of ‘_mac_ipaddr_t’ was here
1150 | type _mac_ipaddr_t _mac_ipaddr_s
| ^
runtime_sysinfo.go:7075:6: error: redefinition of ‘_mactun_info_t’
7075 | type _mactun_info_t _mactun_info_s
| ^
runtime_sysinfo.go:1213:6: note: previous definition of ‘_mactun_info_t’ was
here
1213 | type _mactun_info_t _mactun_info_s
| ^
runtime_sysinfo.go:187:19: error: use of undefined type ‘_timespec’
187 | type _timestruc_t _timespec
| ^
runtime_sysinfo.go:1213:21: error: use of undefined type ‘_mactun_info_s’
1213 | type _mactun_info_t _mactun_info_s
| ^
runtime_sysinfo.go:741:13: error: use of undefined type ‘_ip6_hdr’
741 | type _ip6_t _ip6_hdr
| ^
runtime_sysinfo.go:1079:23: error: use of undefined type ‘_zone_net_addr’
1079 | type _zone_net_addr_t _zone_net_addr
| ^
runtime_sysinfo.go:1127:23: error: use of undefined type ‘_flow_arp_desc_s’
1127 | type _flow_arp_desc_t _flow_arp_desc_s
| ^
runtime_sysinfo.go:1130:22: error: use of undefined type ‘_flow_l3_desc_s’
1130 | type _flow_l3_desc_t _flow_l3_desc_s
| ^
runtime_sysinfo.go:1150:20: error: use of undefined type ‘_mac_ipaddr_s’
1150 | type _mac_ipaddr_t _mac_ipaddr_s
| ^
runtime_sysinfo.go:1210:28: error: use of undefined type ‘_mac_resource_props_s’
1210 | type _mac_resource_props_t _mac_resource_props_s
| ^
runtime_sysinfo.go:1510:17: error: use of undefined type ‘_mld_hdr’
1510 | type _mld_hdr_t _mld_hdr
| ^
runtime_sysinfo.go:1519:17: error: use of undefined type ‘_mld2mar’
1519 | type _mld2mar_t _mld2mar
| ^
runtime_sysinfo.go:1535:29: error: use of undefined type ‘_nd_neighbor_solicit’
1535 | type _nd_neighbor_solicit_t _nd_neighbor_solicit
| ^
runtime_sysinfo.go:1538:28: error: use of undefined type ‘_nd_neighbor_advert’
1538 | type _nd_neighbor_advert_t _nd_neighbor_advert
| ^
runtime_sysinfo.go:1541:21: error: use of undefined type ‘_nd_redirect’
1541 | type _nd_redirect_t _nd_redirect
| ^
runtime_sysinfo.go:1548:28: error: use of undefined type ‘_nd_opt_prefix_info’
1548 | type _nd_opt_prefix_info_t _nd_opt_prefix_info
| ^
make: *** [Makefile:2959: runtime.lo] Error 1
Comparing runtime_sysinfo.go with a slightly older version in two
instances:
-type ___gnuc_va_list *int8
-type ___va_list *int8
-type ___FILE struct { _cnt int32; _ptr *uint8; _base *uint8; _flag uint8;
_magic uint8; Godump_0_pad [2]byte; }
+type ___FILE ___FILE
+type _mld_hdr_t _mld_hdr
-type _mld_hdr_t struct { mld_icmp6_hdr _icmp6_hdr; mld_addr [16]byte; }
+type _mld_hdr_t _mld_hdr
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University