From 7faa23f99c1dcce9d476db9fb92dde6d60ddf367 Mon Sep 17 00:00:00 2001 From: kai Date: Sat, 29 Jun 2013 19:01:42 +0200 Subject: [PATCH] Merge of v2.063.2 --- dmd2/cast.c | 6 +++--- dmd2/expression.c | 53 ++++++++++++++++++++++++++--------------------- dmd2/lexer.c | 7 ++++++- dmd2/mars.c | 14 ++++++++++--- dmd2/template.c | 4 ++-- dmd2/traits.c | 6 ++++++ 6 files changed, 57 insertions(+), 33 deletions(-) diff --git a/dmd2/cast.c b/dmd2/cast.c index ede3f49f..30a92648 100644 --- a/dmd2/cast.c +++ b/dmd2/cast.c @@ -1793,15 +1793,15 @@ Expression *FuncExp::castTo(Scope *sc, Type *t) if (e) { if (e != this) - e = e->castTo(sc, t); - else if (!e->type->equals(t)) + return e->castTo(sc, t); + if (!e->type->equals(t) && e->type->implicitConvTo(t)) { assert(t->ty == Tpointer && t->nextOf()->ty == Tvoid || // Bugzilla 9928 e->type->nextOf()->covariant(t->nextOf()) == 1); e = e->copy(); e->type = t; + return e; } - return e; } return Expression::castTo(sc, t); } diff --git a/dmd2/expression.c b/dmd2/expression.c index 18406d87..e737190d 100644 --- a/dmd2/expression.c +++ b/dmd2/expression.c @@ -8412,6 +8412,8 @@ Lagain: { e1 = new DotVarExp(loc, dte->e1, f); e1 = e1->semantic(sc); + if (e1->op == TOKerror) + return new ErrorExp(); ue = (UnaExp *)e1; } #if 0 @@ -8872,31 +8874,34 @@ Expression *AddrExp::semantic(Scope *sc) { DotTemplateInstanceExp* dti = (DotTemplateInstanceExp *)e1; TemplateInstance *ti = dti->ti; - assert(!ti->semanticRun); - //assert(ti->needsTypeInference(sc)); - ti->semantic(sc); - if (!ti->inst) // if template failed to expand - return new ErrorExp; - Dsymbol *s = ti->inst->toAlias(); - FuncDeclaration *f = s->isFuncDeclaration(); - assert(f); - e1 = new DotVarExp(e1->loc, dti->e1, f); - e1 = e1->semantic(sc); + if (!ti->semanticRun) + { + //assert(ti->needsTypeInference(sc)); + ti->semantic(sc); + if (!ti->inst) // if template failed to expand + return new ErrorExp; + Dsymbol *s = ti->inst->toAlias(); + FuncDeclaration *f = s->isFuncDeclaration(); + assert(f); + e1 = new DotVarExp(e1->loc, dti->e1, f); + e1 = e1->semantic(sc); + } } - else if (e1->op == TOKimport && - ((ScopeExp *)e1)->sds->isTemplateInstance()) + else if (e1->op == TOKimport) { - TemplateInstance *ti = (TemplateInstance *)((ScopeExp *)e1)->sds; - assert(!ti->semanticRun); - //assert(ti->needsTypeInference(sc)); - ti->semantic(sc); - if (!ti->inst) // if template failed to expand - return new ErrorExp; - Dsymbol *s = ti->inst->toAlias(); - FuncDeclaration *f = s->isFuncDeclaration(); - assert(f); - e1 = new VarExp(e1->loc, f); - e1 = e1->semantic(sc); + TemplateInstance *ti = ((ScopeExp *)e1)->sds->isTemplateInstance(); + if (ti && !ti->semanticRun) + { + //assert(ti->needsTypeInference(sc)); + ti->semantic(sc); + if (!ti->inst) // if template failed to expand + return new ErrorExp; + Dsymbol *s = ti->inst->toAlias(); + FuncDeclaration *f = s->isFuncDeclaration(); + assert(f); + e1 = new VarExp(e1->loc, f); + e1 = e1->semantic(sc); + } } e1 = e1->toLvalue(sc, NULL); if (e1->op == TOKerror) @@ -11099,7 +11104,7 @@ Ltupleassign: // Disallow sa = e (Converted to sa[] = e) const char* e1str = e1->toChars(); const char* e2str = e2->toChars(); - if (e2->op == TOKslice || t2->implicitConvTo(t1->nextOf())) + if (e2->op == TOKslice || e2->implicitConvTo(t1->nextOf())) warning("explicit element-wise assignment (%s)[] = %s is better than %s = %s", e1str, e2str, e1str, e2str); else diff --git a/dmd2/lexer.c b/dmd2/lexer.c index b00de9d1..b244c5d5 100644 --- a/dmd2/lexer.c +++ b/dmd2/lexer.c @@ -692,6 +692,7 @@ void Lexer::scan(Token *t) else if (id == Id::VERSIONX) { unsigned major = 0; unsigned minor = 0; + bool point = false; for (const char *p = global.version + 1; 1; p++) { @@ -699,7 +700,11 @@ void Lexer::scan(Token *t) if (isdigit((unsigned char)c)) minor = minor * 10 + c - '0'; else if (c == '.') - { major = minor; + { + if (point) + break; // ignore everything after second '.' + point = true; + major = minor; minor = 0; } else diff --git a/dmd2/mars.c b/dmd2/mars.c index 7f346135..125f7c38 100644 --- a/dmd2/mars.c +++ b/dmd2/mars.c @@ -1,6 +1,5 @@ - // Compiler implementation of the D programming language -// Copyright (c) 1999-2012 by Digital Mars +// Copyright (c) 1999-2013 by Digital Mars // All Rights Reserved // written by Walter Bright // http://www.digitalmars.com @@ -94,7 +93,7 @@ void Global::init() #endif #endif - copyright = "Copyright (c) 1999-2012 by Digital Mars"; + copyright = "Copyright (c) 1999-2013 by Digital Mars"; written = "written by Walter Bright"; #if IN_DMD version = "v" @@ -626,11 +625,18 @@ int tryMain(size_t argc, char *argv[]) { if (strcmp(p + 12, "?") == 0) { +#if PULL93 printf("\ Language changes listed by -transition=id:\n\ =field,3449 do list all non-mutable fields occupies object instance\n\ =tls do list all variables going into thread local storage\n\ "); +#else + printf("\ +Language changes listed by -transition=id:\n\ + =tls do list all variables going into thread local storage\n\ +"); +#endif return EXIT_FAILURE; } if (isdigit((unsigned char)p[12])) @@ -653,8 +659,10 @@ Language changes listed by -transition=id:\n\ { if (strcmp(p + 12, "tls") == 0) global.params.vtls = 1; +#if PULL93 else if (strcmp(p + 12, "field") == 0) global.params.vfield = 1; +#endif } else goto Lerror; diff --git a/dmd2/template.c b/dmd2/template.c index 2daed08d..35687d6a 100644 --- a/dmd2/template.c +++ b/dmd2/template.c @@ -5499,11 +5499,11 @@ void TemplateInstance::semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int f { VarDeclaration *v; if (ea->op == TOKvar && (v = ((VarExp *)ea)->var->isVarDeclaration()) != NULL && - v->storage_class & STCmanifest && !(v->storage_class & STCtemplateparameter)) + !(v->storage_class & STCtemplateparameter)) { if (v->sem < SemanticDone) v->semantic(sc); - // skip optimization for manifest constant + // skip optimization for variable symbols } else { diff --git a/dmd2/traits.c b/dmd2/traits.c index 3594a7c9..b80c517c 100644 --- a/dmd2/traits.c +++ b/dmd2/traits.c @@ -440,6 +440,12 @@ Expression *TraitsExp::semantic(Scope *sc) Dsymbol *s = getDsymbol(o); if (!s) { + #if 0 + Expression *e = isExpression(o); + Type *t = isType(o); + if (e) printf("e = %s %s\n", Token::toChars(e->op), e->toChars()); + if (t) printf("t = %d %s\n", t->ty, t->toChars()); + #endif error("first argument is not a symbol"); goto Lfalse; }