Mercurial > projects > ldc
diff dmd2/inline.c @ 1577:e4f7b5d9c68a
DMD 2.032 Merge.
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Tue, 08 Sep 2009 10:07:56 +0100 |
parents | f62347c22d81 |
children |
line wrap: on
line diff
--- a/dmd2/inline.c Tue Aug 25 21:35:43 2009 +0200 +++ b/dmd2/inline.c Tue Sep 08 10:07:56 2009 +0100 @@ -1,5 +1,5 @@ -// Copyright (c) 1999-2008 by Digital Mars +// Copyright (c) 1999-2009 by Digital Mars // All Rights Reserved // written by Walter Bright // http://www.digitalmars.com @@ -870,7 +870,8 @@ condition = condition->inlineScan(iss); if (increment) increment = increment->inlineScan(iss); - body = body->inlineScan(iss); + if (body) + body = body->inlineScan(iss); return this; } @@ -1072,6 +1073,31 @@ if (ie) { +#if DMDV2 + if (vd->type) + { Type *tb = vd->type->toBasetype(); + if (tb->ty == Tstruct) + { StructDeclaration *sd = ((TypeStruct *)tb)->sym; + if (sd->cpctor) + { /* The problem here is that if the initializer is a + * function call that returns a struct S with a cpctor: + * S s = foo(); + * the postblit is done by the return statement in foo() + * in s2ir.c, the intermediate code generator. + * But, if foo() is inlined and now the code looks like: + * S s = x; + * the postblit is not there, because such assignments + * are rewritten as s.cpctor(&x) by the front end. + * So, the inlining won't get the postblit called. + * Work around by not inlining these cases. + * A proper fix would be to move all the postblit + * additions to the front end. + */ + return; + } + } + } +#endif ie->exp = ie->exp->inlineScan(iss); } } @@ -1499,6 +1525,9 @@ inlineNest++; Expression *eb = fbody->doInline(&ids); inlineNest--; +//eb->type->print(); +//eb->print(); +//eb->dump(0); return Expression::combine(e, eb); }