diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-11-12 15:37:46 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-11-13 14:58:58 +0100 |
commit | 5d4b824faf1e5846ec684a74f93912cf347928df (patch) | |
tree | 3f315f89a5c9204937e5425580254ac995400584 /gcc/d/dmd/cppmangle.c | |
parent | 5fa821bba737cf3e74801c5fe4d3e87a62aa79bf (diff) | |
download | gcc-5d4b824faf1e5846ec684a74f93912cf347928df.zip gcc-5d4b824faf1e5846ec684a74f93912cf347928df.tar.gz gcc-5d4b824faf1e5846ec684a74f93912cf347928df.tar.bz2 |
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.
Diffstat (limited to 'gcc/d/dmd/cppmangle.c')
-rw-r--r-- | gcc/d/dmd/cppmangle.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/gcc/d/dmd/cppmangle.c b/gcc/d/dmd/cppmangle.c index b361d37..3f571fc 100644 --- a/gcc/d/dmd/cppmangle.c +++ b/gcc/d/dmd/cppmangle.c @@ -582,13 +582,21 @@ class CppMangleVisitor : public Visitor //printf("mangle_function(%s)\n", d->toChars()); /* * <mangled-name> ::= _Z <encoding> + */ + buf->writestring("_Z"); + this->mangle_function_encoding(d); + } + + void mangle_function_encoding(FuncDeclaration *d) + { + //printf("mangle_function_encoding(%s)\n", d->toChars()); + /* * <encoding> ::= <function name> <bare-function-type> * ::= <data name> * ::= <special-name> */ TypeFunction *tf = (TypeFunction *)d->type; - buf->writestring("_Z"); if (getFuncTemplateDecl(d)) { /* It's an instance of a function template @@ -1132,3 +1140,13 @@ const char *cppTypeInfoMangleItanium(Dsymbol *s) v.cpp_mangle_name(s, false); return buf.extractChars(); } + +const char *cppThunkMangleItanium(FuncDeclaration *fd, int offset) +{ + //printf("cppThunkMangleItanium(%s)\n", fd.toChars()); + OutBuffer buf; + buf.printf("_ZThn%u_", offset); // "Th" means thunk, "n%u" is the call offset + CppMangleVisitor v(&buf, fd->loc); + v.mangle_function_encoding(fd); + return buf.extractChars(); +} |