Skip to content

Commit

Permalink
Merge pull request #4419 from Ingrater/fix14195
Browse files Browse the repository at this point in the history
Fixed bug 14195: Added C++ mangling for passing function signatures
  • Loading branch information
braddr committed Feb 20, 2015
2 parents b1ace29 + c4ef429 commit a68e1c1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/cppmangle.c
Expand Up @@ -1138,8 +1138,18 @@ class VisualCPPMangler : public Visitor

void visit(TypeFunction *type)
{
// We can mangle pointer to a function, not function.
visit((Type*)type);
const char *arg = mangleFunctionType(type);

if ((flags & IS_DMC))
{
if (checkTypeSaved(type)) return;
}
else
{
buf.writestring("$$A6");
}
buf.writestring(arg);
flags &= ~(IS_NOT_TOP_TYPE | IGNORE_CONST);
}

void visit(TypeStruct *type)
Expand Down
27 changes: 27 additions & 0 deletions test/runnable/cppa.d
Expand Up @@ -707,6 +707,32 @@ extern(C++, N13337.M13337)
void foo13337(S13337 s);
}

/****************************************/
// 14195

struct Delegate1(T) {}
struct Delegate2(T1, T2) {}

template Signature(T)
{
alias Signature = typeof(*(T.init));
}

extern(C++)
{
alias del1_t = Delegate1!(Signature!(void function()));
alias del2_t = Delegate2!(Signature!(int function(float, double)), Signature!(int function(float, double)));
void test14195a(del1_t);
void test14195b(del2_t);
}

void test14195()
{
test14195a(del1_t());
test14195b(del2_t());
}


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

void main()
Expand Down Expand Up @@ -736,6 +762,7 @@ void main()
func13707();
func13932(S13932!(-1)(0));
foo13337(S13337());
test14195();

printf("Success\n");
}
19 changes: 19 additions & 0 deletions test/runnable/extra-files/cppb.cpp
Expand Up @@ -454,4 +454,23 @@ namespace N13337 {
}
}

/****************************************/
// 14195

template <typename T>
struct Delegate1 {};

template <typename R1>
struct Delegate1 < R1() > {};

template <typename T1, typename T2>
struct Delegate2 {};

template < typename R1, typename T1, typename T2, typename R2, typename T3, typename T4 >
struct Delegate2<R1(T1, T2), R2(T3, T4)> {};

void test14195a(Delegate1<void()> func) {}

void test14195b(Delegate2<int(float, double), int(float, double)> func) {}

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

0 comments on commit a68e1c1

Please sign in to comment.