Skip to content

Commit

Permalink
Merge pull request #5537 from Kozzi11/fix15802
Browse files Browse the repository at this point in the history
Fix issue 15802
  • Loading branch information
WalterBright committed Mar 21, 2016
2 parents fc088d4 + 1686f05 commit dfc005a
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/cppmangle.d
Expand Up @@ -119,7 +119,7 @@ static if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TAR
if (!skipname && !substitute(ti.tempdecl))
{
store(ti.tempdecl);
const(char)* name = ti.toAlias().ident.toChars();
const(char)* name = ti.tempdecl.toAlias().ident.toChars();
buf.printf("%d%s", strlen(name), name);
}
buf.writeByte('I');
Expand Down Expand Up @@ -429,7 +429,9 @@ static if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TAR
TypeFunction tf = cast(TypeFunction)d.type;
buf.writestring("_Z");
Dsymbol p = d.toParent();
if (p && !p.isModule() && tf.linkage == LINKcpp)
TemplateDeclaration ftd = getFuncTemplateDecl(d);

if (p && !p.isModule() && tf.linkage == LINKcpp && !ftd)
{
buf.writeByte('N');
if (d.type.isConst())
Expand Down Expand Up @@ -469,6 +471,13 @@ static if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TAR
}
buf.writeByte('E');
}
else if (ftd)
{
source_name(p);
this.is_top_level = true;
tf.nextOf().accept(this);
this.is_top_level = false;
}
else
{
source_name(d);
Expand Down
10 changes: 10 additions & 0 deletions test/compilable/test15802.d
@@ -0,0 +1,10 @@
extern(C++) {
template Foo(T) {
static int boo();
}
}

void main()
{
string s = Foo!(int).boo.mangleof;
}
31 changes: 31 additions & 0 deletions test/runnable/cppa.d
Expand Up @@ -1084,6 +1084,35 @@ void test15610()
c.f();
}

/****************************************/
// 15372

extern(C++) int foo15372(T)(T v);

void test15372()
{
version(Windows){}
else
assert(foo15372!int(1) == 1);
}

/****************************************/
// 15802

extern(C++) {
template Foo15802(T) {
static int boo(T v);
}
}

void test15802()
{
version(Windows){}
else
assert(Foo15802!(int).boo(1) == 1);
}


/****************************************/

void main()
Expand Down Expand Up @@ -1123,6 +1152,8 @@ void main()
testeh3();
test15579();
test15610();
test15372();
test15802();

printf("Success\n");
}
28 changes: 28 additions & 0 deletions test/runnable/extra-files/cppb.cpp
Expand Up @@ -695,4 +695,32 @@ void Derived2::f()
}

/******************************************/
// 15372

template <typename T>
int foo15372(int value)
{
return value;
}

void test15372b()
{
int t = foo15372<int>(1);
}

/****************************************/
// 15802
template <typename T>
class Foo15802
{
public:
static int boo(int value)
{
return value;
}
};

void test15802b()
{
int t = Foo15802<int>::boo(1);
}

0 comments on commit dfc005a

Please sign in to comment.