From 2c081edfcdbe0868534da63b7afb4d3fc7ed0d89 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Fri, 22 Apr 2011 19:08:44 +0200 Subject: [PATCH] Merged DMD commit ac685a4b2ec07af83f687f41496e3af02e3f0fe: bugzilla 190 and 4753 --- dmd/expression.c | 6 +++++- dmd/mtype.c | 10 ++++++++++ dmd/mtype.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/dmd/expression.c b/dmd/expression.c index 18728dc5..b16d3aef 100644 --- a/dmd/expression.c +++ b/dmd/expression.c @@ -3994,6 +3994,9 @@ Expression *VarExp::semantic(Scope *sc) #endif } + if (type && !type->deco) + type = type->semantic(loc, sc); + /* Fix for 1161 doesn't work because it causes protection * problems when instantiating imported templates passing private * variables as alias template parameters. @@ -5562,7 +5565,8 @@ Expression *DotIdExp::semantic(Scope *sc) e->type = v->type; } } - return e->deref(); + e = e->deref(); + return e->semantic(sc); } FuncDeclaration *f = s->isFuncDeclaration(); diff --git a/dmd/mtype.c b/dmd/mtype.c index 81678501..2bffa933 100644 --- a/dmd/mtype.c +++ b/dmd/mtype.c @@ -3935,6 +3935,7 @@ TypeTypeof::TypeTypeof(Loc loc, Expression *exp) : TypeQualified(Ttypeof, loc) { this->exp = exp; + inuse = 0; } Type *TypeTypeof::syntaxCopy() @@ -3981,6 +3982,13 @@ Type *TypeTypeof::semantic(Loc loc, Scope *sc) //printf("TypeTypeof::semantic() %p\n", this); //static int nest; if (++nest == 50) *(char*)0=0; + if (inuse) + { + inuse = 2; + error(loc, "circular typeof definition"); + return Type::terror; + } + inuse++; #if 0 /* Special case for typeof(this) and typeof(super) since both @@ -4077,9 +4085,11 @@ Type *TypeTypeof::semantic(Loc loc, Scope *sc) goto Lerr; } } + inuse--; return t; Lerr: + inuse--; return terror; } diff --git a/dmd/mtype.h b/dmd/mtype.h index ccfbd8be..083861e4 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -597,6 +597,7 @@ struct TypeInstance : TypeQualified struct TypeTypeof : TypeQualified { Expression *exp; + int inuse; TypeTypeof(Loc loc, Expression *exp); Type *syntaxCopy();