[svn r176] Fixed a bug with class constructors.

This commit is contained in:
Tomas Lindquist Olsen 2008-05-04 04:35:27 +02:00
parent 7ae4bc6477
commit a522719b85
5 changed files with 40 additions and 2 deletions

View file

@ -32,6 +32,8 @@
#include "mem.h"
#include "gen/logger.h"
int executecmd(char *cmd, char *args, int useenv);
int executearg0(char *cmd, char *args);
@ -41,6 +43,8 @@ int executearg0(char *cmd, char *args);
int runLINK()
{
Logger::println("*** Linking executable ***");
#if _WIN32
assert(0 && "linking not done for win32");
@ -321,7 +325,7 @@ int runLINK()
printf("--- errorlevel %d\n", status);
return status;
#else
printf ("Linking is not yet supported for this version of LLVMDMD.\n");
printf ("Linking is not yet supported for this version of LLVMDC.\n");
return -1;
#endif
}

View file

@ -793,8 +793,11 @@ DValue* DtoNewClass(TypeClass* tc, NewExp* newexp)
}
// call constructor
if (newexp->arguments)
if (newexp->member)
{
assert(newexp->arguments != NULL);
return DtoCallClassCtor(tc, newexp->member, newexp->arguments, mem);
}
// return default constructed class
return new DImValue(tc, mem, false);

View file

@ -1628,6 +1628,7 @@ void DtoConstInitGlobal(VarDeclaration* vd)
_type = _init->getType();
llvm::cast<llvm::OpaqueType>(gIR->irDsymbol[vd].irGlobal->type.get())->refineAbstractTypeTo(_type);
_type = gIR->irDsymbol[vd].irGlobal->type.get();
//_type->dump();
assert(!_type->isAbstract());
llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(gIR->irDsymbol[vd].irGlobal->value);

View file

@ -749,6 +749,7 @@ tangotests
tangotests/a.d
tangotests/b.d
tangotests/c.d
tangotests/constructors.d
tangotests/d.d
tangotests/e.d
tangotests/f.d

29
tangotests/constructors.d Normal file
View file

@ -0,0 +1,29 @@
import tango.io.Console;
class C
{
this()
{
Cout("C()").newline;
}
this(char[] str)
{
Cout("C(")(str)(")").newline;
}
}
class D : C
{
this()
{
super("D");
Cout("D()").newline;
}
}
void main()
{
auto c1 = new C();
auto c2 = new C("C");
auto d = new D();
}