diff --git a/src/dmd/attrib.d b/src/dmd/attrib.d index 7035ec3eba03..9c5978e8d059 100644 --- a/src/dmd/attrib.d +++ b/src/dmd/attrib.d @@ -435,6 +435,13 @@ extern (C++) final class CPPMangleDeclaration : AttribDeclaration sc.aligndecl, sc.inlining); } + override void setScope(Scope* sc) + { + if (decl) + Dsymbol.setScope(sc); // for forward reference + return AttribDeclaration.setScope(sc); + } + override const(char)* toChars() const { return toString().ptr; diff --git a/src/dmd/attrib.h b/src/dmd/attrib.h index 40fa3940d5ad..f7e87b6105cd 100644 --- a/src/dmd/attrib.h +++ b/src/dmd/attrib.h @@ -88,6 +88,7 @@ class CPPMangleDeclaration : public AttribDeclaration Dsymbol *syntaxCopy(Dsymbol *s); Scope *newScope(Scope *sc); + void setScope(Scope *sc); const char *toChars() const; void accept(Visitor *v) { v->visit(this); } }; diff --git a/test/compilable/cppmangle.d b/test/compilable/cppmangle.d index 1a84059a56e8..b8be755c5641 100644 --- a/test/compilable/cppmangle.d +++ b/test/compilable/cppmangle.d @@ -1251,3 +1251,16 @@ extern(C++, `bar`) { void func19542(T)(); } + +// https://issues.dlang.org/show_bug.cgi?id=20700 +version (Windows) +extern(C++) +{ + void test20700_1(const ref Struct200700); + extern(C++, class) struct Struct200700 {} + void test20700_2(const ref Struct200700); + + // Note: Needs to be `BV` (`class`), not `BU` (`struct`) + static assert(test20700_1.mangleof == `?test20700_1@@YAXABVStruct200700@@@Z`); + static assert(test20700_2.mangleof == `?test20700_2@@YAXABVStruct200700@@@Z`); +}