diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-04-29 10:19:55 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-04-29 10:36:00 +0200 |
commit | 75f758a703924184fc07b01a138bb6f0028d077c (patch) | |
tree | 9b90b2c92161b246f7acd4494c5b1a2a3e4f1d09 /gcc/d/dmd/dclass.c | |
parent | d81bc2af7d2700888e414eb5a322ff5f5b0df0bb (diff) | |
download | gcc-75f758a703924184fc07b01a138bb6f0028d077c.zip gcc-75f758a703924184fc07b01a138bb6f0028d077c.tar.gz gcc-75f758a703924184fc07b01a138bb6f0028d077c.tar.bz2 |
d: Merge bug fix from upstream dmd 06160ccae
Adds classKind information to the front-end AST, which in turn allows us
to fix code generation of type names for extern(C) and extern(C++)
structs and classes. Inspecting such types inside a debugger now just
works without the need to 'cast(module_name.cxx_type)'.
gcc/d/ChangeLog:
* d-codegen.cc (d_decl_context): Don't include module in the name of
class and struct types that aren't extern(D).
Diffstat (limited to 'gcc/d/dmd/dclass.c')
-rw-r--r-- | gcc/d/dmd/dclass.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/gcc/d/dmd/dclass.c b/gcc/d/dmd/dclass.c index 4609d6a..a2009a6 100644 --- a/gcc/d/dmd/dclass.c +++ b/gcc/d/dmd/dclass.c @@ -240,12 +240,10 @@ ClassDeclaration::ClassDeclaration(Loc loc, Identifier *id, BaseClasses *basecla } com = false; - cpp = false; isscope = false; isabstract = ABSfwdref; inuse = 0; baseok = BASEOKnone; - isobjc = false; cpp_type_info_ptr_sym = NULL; } @@ -389,7 +387,7 @@ void ClassDeclaration::semantic(Scope *sc) userAttribDecl = sc->userAttribDecl; if (sc->linkage == LINKcpp) - cpp = true; + classKind = ClassKind::cpp; if (sc->linkage == LINKobjc) objc()->setObjc(this); } @@ -555,7 +553,7 @@ void ClassDeclaration::semantic(Scope *sc) baseok = BASEOKdone; // If no base class, and this is not an Object, use Object as base class - if (!baseClass && ident != Id::Object && !cpp) + if (!baseClass && ident != Id::Object && !isCPPclass()) { if (!object || object->errors) badObjectDotD(this); @@ -583,7 +581,7 @@ void ClassDeclaration::semantic(Scope *sc) if (baseClass->isCOMclass()) com = true; if (baseClass->isCPPclass()) - cpp = true; + classKind = ClassKind::cpp; if (baseClass->isscope) isscope = true; enclosing = baseClass->enclosing; @@ -600,7 +598,7 @@ void ClassDeclaration::semantic(Scope *sc) // then this is a COM interface too. if (b->sym->isCOMinterface()) com = true; - if (cpp && !b->sym->isCPPinterface()) + if (isCPPclass() && !b->sym->isCPPinterface()) { ::error(loc, "C++ class '%s' cannot implement D interface '%s'", toPrettyChars(), b->sym->toPrettyChars()); @@ -675,7 +673,7 @@ Lancestorsdone: // initialize vtbl if (baseClass) { - if (cpp && baseClass->vtbl.dim == 0) + if (isCPPclass() && baseClass->vtbl.dim == 0) { error("C++ base class %s needs at least one virtual function", baseClass->toChars()); } @@ -1087,7 +1085,7 @@ void ClassDeclaration::finalizeSize() alignsize = baseClass->alignsize; structsize = baseClass->structsize; - if (cpp && global.params.isWindows) + if (isCPPclass() && global.params.isWindows) structsize = (structsize + alignsize - 1) & ~(alignsize - 1); } else if (isInterfaceDeclaration()) @@ -1102,7 +1100,7 @@ void ClassDeclaration::finalizeSize() { alignsize = Target::ptrsize; structsize = Target::ptrsize; // allow room for __vptr - if (!cpp) + if (!isCPPclass()) structsize += Target::ptrsize; // allow room for __monitor } @@ -1299,7 +1297,7 @@ bool ClassDeclaration::isCOMinterface() const bool ClassDeclaration::isCPPclass() const { - return cpp; + return classKind == ClassKind::cpp; } bool ClassDeclaration::isCPPinterface() const @@ -1378,7 +1376,7 @@ bool ClassDeclaration::isAbstract() int ClassDeclaration::vtblOffset() const { - return cpp ? 0 : 1; + return classKind == ClassKind::cpp ? 0 : 1; } /**************************************** @@ -1405,7 +1403,7 @@ InterfaceDeclaration::InterfaceDeclaration(Loc loc, Identifier *id, BaseClasses if (id == Id::IUnknown) // IUnknown is the root of all COM interfaces { com = true; - cpp = true; // IUnknown is also a C++ interface + classKind = ClassKind::cpp; // IUnknown is also a C++ interface } } @@ -1422,9 +1420,9 @@ Scope *InterfaceDeclaration::newScope(Scope *sc) Scope *sc2 = ClassDeclaration::newScope(sc); if (com) sc2->linkage = LINKwindows; - else if (cpp) + else if (classKind == ClassKind::cpp) sc2->linkage = LINKcpp; - else if (isobjc) + else if (classKind == ClassKind::objc) sc2->linkage = LINKobjc; return sc2; } @@ -1523,7 +1521,7 @@ void InterfaceDeclaration::semantic(Scope *sc) } if (!baseclasses->dim && sc->linkage == LINKcpp) - cpp = true; + classKind = ClassKind::cpp; if (sc->linkage == LINKobjc) objc()->setObjc(this); @@ -1605,7 +1603,7 @@ void InterfaceDeclaration::semantic(Scope *sc) if (b->sym->isCOMinterface()) com = true; if (b->sym->isCPPinterface()) - cpp = true; + classKind = ClassKind::cpp; } interfaceSemantic(sc); @@ -1817,7 +1815,7 @@ bool InterfaceDeclaration::isCOMinterface() const bool InterfaceDeclaration::isCPPinterface() const { - return cpp; + return classKind == ClassKind::cpp; } /******************************************* |