changeset 1169:2bff538fa3b9

Automated merge with http://hg.dsource.org/projects/ldc
author Christian Kamm <kamm incasoftware de>
date Sun, 29 Mar 2009 11:44:32 +0200
parents ed4b050ada45 (current diff) ab186e535e72 (diff)
children e40c65bd8c5d
files
diffstat 3 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/expression.c	Sun Mar 29 03:53:22 2009 +0200
+++ b/dmd/expression.c	Sun Mar 29 11:44:32 2009 +0200
@@ -3234,10 +3234,13 @@
 }
 #endif
 
+/*
+Removed in LDC. See declaration.
 Expression *StructLiteralExp::toLvalue(Scope *sc, Expression *e)
 {
     return this;
 }
+*/
 
 
 int StructLiteralExp::checkSideEffect(int flag)
--- a/dmd/expression.h	Sun Mar 29 03:53:22 2009 +0200
+++ b/dmd/expression.h	Sun Mar 29 11:44:32 2009 +0200
@@ -502,7 +502,9 @@
     void scanForNestedRef(Scope *sc);
     Expression *optimize(int result);
     Expression *interpret(InterState *istate);
-    Expression *toLvalue(Scope *sc, Expression *e);
+    // LDC: struct literals aren't lvalues! Taking their address can lead to 
+    //      incorrect behavior, see LDC#218, DMD#2682
+    // Expression *toLvalue(Scope *sc, Expression *e);
 
     int inlineCost(InlineCostState *ics);
     Expression *doInline(InlineDoState *ids);
--- a/dmd/optimize.c	Sun Mar 29 03:53:22 2009 +0200
+++ b/dmd/optimize.c	Sun Mar 29 11:44:32 2009 +0200
@@ -46,7 +46,7 @@
     if (e1->op == TOKvar)
     {	VarExp *ve = (VarExp *)e1;
 	VarDeclaration *v = ve->var->isVarDeclaration();
-	if (v && v->isConst() && v->init && !v->init->isStructInitializer())
+	if (v && v->isConst() && v->init)
 	{   Expression *ei = v->init->toExpression();
 	    if (ei && ei->type)
 		e1 = ei;