d: Fix ICE in finish_thunk (PR97644)
authorIain Buclaw <ibuclaw@gdcproject.org>
Thu, 12 Nov 2020 14:37:46 +0000 (15:37 +0100)
committerIain Buclaw <ibuclaw@gdcproject.org>
Fri, 13 Nov 2020 13:58:58 +0000 (14:58 +0100)
commit5d4b824faf1e5846ec684a74f93912cf347928df
tree3f315f89a5c9204937e5425580254ac995400584
parent5fa821bba737cf3e74801c5fe4d3e87a62aa79bf
d: Fix ICE in finish_thunk (PR97644)

Because this what the upstream reference compiler did, thunks for the D
front-end were associated with the class definition, so were forced
code-gen even if the target function was extern.  This has now been
changed so there are now only generated if there is a function
definition, fixing the ICE that occurred in PR 97644, which was caused
by calling expand_thunk() early.

gcc/d/ChangeLog:

PR d/97644
* dmd/MERGE: Merge upstream dmd 95044d8e4.
* d-target.cc (TargetCPP::thunkMangle): New function.
* decl.cc (finish_thunk): Don't force expand thunks for external
functions.
(make_thunk): Emit thunks only if the function has a definition.
Generate correct mangling for thunks to C++ classes.

gcc/testsuite/ChangeLog:

* gdc.dg/pr92216.d: Update scan-assember.
gcc/d/d-target.cc
gcc/d/decl.cc
gcc/d/dmd/MERGE
gcc/d/dmd/cppmangle.c
gcc/d/dmd/mangle.h
gcc/d/dmd/target.h
gcc/testsuite/gdc.dg/pr92216.d