Skip to content

Commit

Permalink
Fix issue 18957 - extern(C++) doesn't mangle 'std' correctly on posix…
Browse files Browse the repository at this point in the history
… systems
  • Loading branch information
TurkeyMan committed Jun 8, 2018
1 parent da13edb commit 4b17e0b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/dmd/cppmangle.d
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,12 @@ private final class CppMangleVisitor : Visitor
{
buf.writeByte('N');
if (write_prefix)
prefix_name(p);
{
if (isStd(p))
buf.writestring("St");
else
prefix_name(p);
}
source_name(se);
buf.writeByte('E');
}
Expand Down
21 changes: 17 additions & 4 deletions test/compilable/cppmangle.d
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ extern (C++, std)
{
uint foof();
}

struct test18957 {}
}

version (linux)
Expand Down Expand Up @@ -726,8 +728,19 @@ extern(C++, Namespace18922)
import cppmangle2;
void func18922(Struct18922) {}

version (Posix)
static assert(func18922.mangleof == "_ZN14Namespace189229func18922ENS_11Struct18922E");
else version(Windows)
static assert(func18922.mangleof == "?func18922@Namespace18922@@YAXUStruct18922@1@@Z");
version (Posix)
static assert(func18922.mangleof == "_ZN14Namespace189229func18922ENS_11Struct18922E");
else version(Windows)
static assert(func18922.mangleof == "?func18922@Namespace18922@@YAXUStruct18922@1@@Z");
}

/**************************************/
// https://issues.dlang.org/show_bug.cgi?id=18957
// extern(C++) doesn't mangle 'std' correctly on posix systems

version (Posix)
{
extern (C++) void test18957(ref const(std.test18957) t) {}

static assert(test18957.mangleof == "_Z9test18957RKNSt9test18957E");
}

0 comments on commit 4b17e0b

Please sign in to comment.