mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 08:30:47 +03:00
[svn r176] Fixed a bug with class constructors.
This commit is contained in:
parent
7ae4bc6477
commit
a522719b85
5 changed files with 40 additions and 2 deletions
|
@ -32,6 +32,8 @@
|
||||||
|
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
|
|
||||||
|
#include "gen/logger.h"
|
||||||
|
|
||||||
int executecmd(char *cmd, char *args, int useenv);
|
int executecmd(char *cmd, char *args, int useenv);
|
||||||
int executearg0(char *cmd, char *args);
|
int executearg0(char *cmd, char *args);
|
||||||
|
|
||||||
|
@ -41,6 +43,8 @@ int executearg0(char *cmd, char *args);
|
||||||
|
|
||||||
int runLINK()
|
int runLINK()
|
||||||
{
|
{
|
||||||
|
Logger::println("*** Linking executable ***");
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
assert(0 && "linking not done for win32");
|
assert(0 && "linking not done for win32");
|
||||||
|
|
||||||
|
@ -321,7 +325,7 @@ int runLINK()
|
||||||
printf("--- errorlevel %d\n", status);
|
printf("--- errorlevel %d\n", status);
|
||||||
return status;
|
return status;
|
||||||
#else
|
#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;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -793,8 +793,11 @@ DValue* DtoNewClass(TypeClass* tc, NewExp* newexp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// call constructor
|
// call constructor
|
||||||
if (newexp->arguments)
|
if (newexp->member)
|
||||||
|
{
|
||||||
|
assert(newexp->arguments != NULL);
|
||||||
return DtoCallClassCtor(tc, newexp->member, newexp->arguments, mem);
|
return DtoCallClassCtor(tc, newexp->member, newexp->arguments, mem);
|
||||||
|
}
|
||||||
|
|
||||||
// return default constructed class
|
// return default constructed class
|
||||||
return new DImValue(tc, mem, false);
|
return new DImValue(tc, mem, false);
|
||||||
|
|
|
@ -1628,6 +1628,7 @@ void DtoConstInitGlobal(VarDeclaration* vd)
|
||||||
_type = _init->getType();
|
_type = _init->getType();
|
||||||
llvm::cast<llvm::OpaqueType>(gIR->irDsymbol[vd].irGlobal->type.get())->refineAbstractTypeTo(_type);
|
llvm::cast<llvm::OpaqueType>(gIR->irDsymbol[vd].irGlobal->type.get())->refineAbstractTypeTo(_type);
|
||||||
_type = gIR->irDsymbol[vd].irGlobal->type.get();
|
_type = gIR->irDsymbol[vd].irGlobal->type.get();
|
||||||
|
//_type->dump();
|
||||||
assert(!_type->isAbstract());
|
assert(!_type->isAbstract());
|
||||||
|
|
||||||
llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(gIR->irDsymbol[vd].irGlobal->value);
|
llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(gIR->irDsymbol[vd].irGlobal->value);
|
||||||
|
|
|
@ -749,6 +749,7 @@ tangotests
|
||||||
tangotests/a.d
|
tangotests/a.d
|
||||||
tangotests/b.d
|
tangotests/b.d
|
||||||
tangotests/c.d
|
tangotests/c.d
|
||||||
|
tangotests/constructors.d
|
||||||
tangotests/d.d
|
tangotests/d.d
|
||||||
tangotests/e.d
|
tangotests/e.d
|
||||||
tangotests/f.d
|
tangotests/f.d
|
||||||
|
|
29
tangotests/constructors.d
Normal file
29
tangotests/constructors.d
Normal 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();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue