changeset 160:b77664331d06 trunk

[svn r176] Fixed a bug with class constructors.
author lindquist
date Sun, 04 May 2008 04:35:27 +0200
parents 5acec6b2eef8
children 3a891cfcd249
files dmd/link.c gen/classes.cpp gen/tollvm.cpp llvmdc.kdevelop.filelist tangotests/constructors.d
diffstat 5 files changed, 40 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/link.c	Thu May 01 15:15:28 2008 +0200
+++ b/dmd/link.c	Sun May 04 04:35:27 2008 +0200
@@ -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 runLINK()
 {
+    Logger::println("*** Linking executable ***");
+
 #if _WIN32
     assert(0 && "linking not done for win32");
 
@@ -321,7 +325,7 @@
 	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
 }
--- a/gen/classes.cpp	Thu May 01 15:15:28 2008 +0200
+++ b/gen/classes.cpp	Sun May 04 04:35:27 2008 +0200
@@ -793,8 +793,11 @@
     }
 
     // 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);
--- a/gen/tollvm.cpp	Thu May 01 15:15:28 2008 +0200
+++ b/gen/tollvm.cpp	Sun May 04 04:35:27 2008 +0200
@@ -1628,6 +1628,7 @@
         _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);
--- a/llvmdc.kdevelop.filelist	Thu May 01 15:15:28 2008 +0200
+++ b/llvmdc.kdevelop.filelist	Sun May 04 04:35:27 2008 +0200
@@ -749,6 +749,7 @@
 tangotests/a.d
 tangotests/b.d
 tangotests/c.d
+tangotests/constructors.d
 tangotests/d.d
 tangotests/e.d
 tangotests/f.d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tangotests/constructors.d	Sun May 04 04:35:27 2008 +0200
@@ -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();
+}