Mercurial > projects > ldc
diff dmd/mtype.c @ 35:3cfcb944304e trunk
[svn r39] * Updated to DMD 1.022 with the exception of:
Bugzilla 278: dmd.conf search path doesn't work
This fix was causing crashes for me :/ So for it's the old behaviour
author | lindquist |
---|---|
date | Tue, 09 Oct 2007 06:21:30 +0200 |
parents | d3ee9efe20e2 |
children | 70d6113eeb8c |
line wrap: on
line diff
--- a/dmd/mtype.c Tue Oct 09 02:50:00 2007 +0200 +++ b/dmd/mtype.c Tue Oct 09 06:21:30 2007 +0200 @@ -554,6 +554,8 @@ } else if (ident == Id::init) { + if (ty == Tvoid) + error(loc, "void does not have an initializer"); e = defaultInit(); e->loc = loc; } @@ -642,7 +644,9 @@ return e; } #endif - return defaultInit(); + Expression *ex = defaultInit(); + ex->loc = e->loc; + return ex; } } if (ident == Id::typeinfo) @@ -3760,6 +3764,8 @@ #if LOGDOTEXP printf("TypeEnum::dotExp(e = '%s', ident = '%s') '%s'\n", e->toChars(), ident->toChars(), toChars()); #endif + if (!sym->symtab) + goto Lfwd; s = sym->symtab->lookup(ident); if (!s) { @@ -3769,6 +3775,10 @@ em = m->value->copy(); em->loc = e->loc; return em; + +Lfwd: + error(e->loc, "forward reference of %s.%s", toChars(), ident->toChars()); + return new IntegerExp(0, 0, this); } Expression *TypeEnum::getProperty(Loc loc, Identifier *ident) @@ -4472,6 +4482,9 @@ t = ClassDeclaration::classinfo->type; if (e->op == TOKtype || e->op == TOKdottype) { + /* For type.classinfo, we know the classinfo + * at compile time. + */ if (!sym->vclassinfo) sym->vclassinfo = new ClassInfoDeclaration(sym); e = new VarExp(e->loc, sym->vclassinfo); @@ -4479,13 +4492,25 @@ e->type = t; // do this so we don't get redundant dereference } else - { + { /* For class objects, the classinfo reference is the first + * entry in the vtbl[] + */ e = new PtrExp(e->loc, e); e->type = t->pointerTo(); if (sym->isInterfaceDeclaration()) { - if (sym->isCOMclass()) + if (sym->isCOMinterface()) + { /* COM interface vtbl[]s are different in that the + * first entry is always pointer to QueryInterface(). + * We can't get a .classinfo for it. + */ error(e->loc, "no .classinfo for COM interface objects"); + } + /* For an interface, the first entry in the vtbl[] + * is actually a pointer to an instance of struct Interface. + * The first member of Interface is the .classinfo, + * so add an extra pointer indirection. + */ e->type = e->type->pointerTo(); e = new PtrExp(e->loc, e); e->type = t->pointerTo();