1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
diff -Nurp a/src/dmd/declaration.c b/src/dmd/declaration.c
--- a/src/dmd/declaration.c 2012-04-17 12:02:10.231883129 +0200
+++ b/src/dmd/declaration.c 2012-04-17 12:37:45.585187488 +0200
@@ -1361,11 +1361,17 @@ Lnomatch:
e->op = TOKblit;
}
e->type = t;
- (*pinit) = new CommaExp(loc, e, (*pinit));
- /* Replace __ctmp being constructed with e1
+ /* Replace __ctmp being constructed with e1.
+ * We need to copy constructor call expression,
+ * because it may be used in other place.
*/
- dve->e1 = e1;
+ DotVarExp *dvx = (DotVarExp *)dve->copy();
+ dvx->e1 = e1;
+ CallExp *cx = (CallExp *)ce->copy();
+ cx->e1 = dvx;
+
+ (*pinit) = new CommaExp(loc, e, cx);
(*pinit) = (*pinit)->semantic(sc);
goto Ldtor;
}
diff -Nurp a/src/dmd/opover.c b/src/dmd/opover.c
--- a/src/dmd/opover.c 2012-04-17 12:02:10.226883191 +0200
+++ b/src/dmd/opover.c 2012-04-17 12:37:45.585187488 +0200
@@ -354,9 +354,11 @@ Expression *UnaExp::op_overload(Scope *s
/* Rewrite op(e1) as:
* op(e1.aliasthis)
*/
- UnaExp *e = (UnaExp *)syntaxCopy();
- e->e1 = new DotIdExp(loc, e->e1, ad->aliasthis->ident);
- return e->trySemantic(sc);
+ Expression *e1 = new DotIdExp(loc, this->e1, ad->aliasthis->ident);
+ Expression *e = copy();
+ ((UnaExp *)e)->e1 = e1;
+ e = e->trySemantic(sc);
+ return e;
}
#endif
}
@@ -411,9 +413,11 @@ Expression *ArrayExp::op_overload(Scope
/* Rewrite op(e1) as:
* op(e1.aliasthis)
*/
- UnaExp *e = (UnaExp *)syntaxCopy();
- e->e1 = new DotIdExp(loc, e->e1, ad->aliasthis->ident);
- return e->trySemantic(sc);
+ Expression *e1 = new DotIdExp(loc, this->e1, ad->aliasthis->ident);
+ Expression *e = copy();
+ ((UnaExp *)e)->e1 = e1;
+ e = e->trySemantic(sc);
+ return e;
}
}
return NULL;
@@ -456,9 +460,11 @@ Expression *CastExp::op_overload(Scope *
/* Rewrite op(e1) as:
* op(e1.aliasthis)
*/
- UnaExp *e = (UnaExp *)syntaxCopy();
- e->e1 = new DotIdExp(loc, e->e1, ad->aliasthis->ident);
- return e->trySemantic(sc);
+ Expression *e1 = new DotIdExp(loc, this->e1, ad->aliasthis->ident);
+ Expression *e = copy();
+ ((UnaExp *)e)->e1 = e1;
+ e = e->trySemantic(sc);
+ return e;
}
}
return NULL;
@@ -714,9 +720,11 @@ L1:
/* Rewrite (e1 op e2) as:
* (e1.aliasthis op e2)
*/
- BinExp *e = (BinExp *)syntaxCopy();
- e->e1 = new DotIdExp(loc, e->e1, ad1->aliasthis->ident);
- return e->trySemantic(sc);
+ Expression *e1 = new DotIdExp(loc, this->e1, ad1->aliasthis->ident);
+ Expression *e = copy();
+ ((BinExp *)e)->e1 = e1;
+ e = e->trySemantic(sc);
+ return e;
}
// Try alias this on second operand
@@ -729,9 +737,11 @@ L1:
/* Rewrite (e1 op e2) as:
* (e1 op e2.aliasthis)
*/
- BinExp *e = (BinExp *)syntaxCopy();
- e->e2 = new DotIdExp(loc, e->e2, ad2->aliasthis->ident);
- return e->trySemantic(sc);
+ Expression *e2 = new DotIdExp(loc, this->e2, ad2->aliasthis->ident);
+ Expression *e = copy();
+ ((BinExp *)e)->e2 = e2;
+ e = e->trySemantic(sc);
+ return e;
}
#endif
return NULL;
@@ -883,9 +893,11 @@ Expression *BinExp::compare_overload(Sco
/* Rewrite (e1 op e2) as:
* (e1.aliasthis op e2)
*/
- BinExp *e = (BinExp *)syntaxCopy();
- e->e1 = new DotIdExp(loc, e->e1, ad1->aliasthis->ident);
- return e->trySemantic(sc);
+ Expression *e1 = new DotIdExp(loc, this->e1, ad1->aliasthis->ident);
+ Expression *e = copy();
+ ((BinExp *)e)->e1 = e1;
+ e = e->trySemantic(sc);
+ return e;
}
// Try alias this on second operand
@@ -894,9 +906,11 @@ Expression *BinExp::compare_overload(Sco
/* Rewrite (e1 op e2) as:
* (e1 op e2.aliasthis)
*/
- BinExp *e = (BinExp *)syntaxCopy();
- e->e2 = new DotIdExp(loc, e->e2, ad2->aliasthis->ident);
- return e->trySemantic(sc);
+ Expression *e2 = new DotIdExp(loc, this->e2, ad2->aliasthis->ident);
+ Expression *e = copy();
+ ((BinExp *)e)->e2 = e2;
+ e = e->trySemantic(sc);
+ return e;
}
return NULL;
@@ -1131,9 +1145,11 @@ L1:
/* Rewrite (e1 op e2) as:
* (e1.aliasthis op e2)
*/
- BinExp *e = (BinExp *)syntaxCopy();
- e->e1 = new DotIdExp(loc, e->e1, ad1->aliasthis->ident);
- return e->trySemantic(sc);
+ Expression *e1 = new DotIdExp(loc, this->e1, ad1->aliasthis->ident);
+ Expression *e = copy();
+ ((BinExp *)e)->e1 = e1;
+ e = e->trySemantic(sc);
+ return e;
}
// Try alias this on second operand
@@ -1143,9 +1159,11 @@ L1:
/* Rewrite (e1 op e2) as:
* (e1 op e2.aliasthis)
*/
- BinExp *e = (BinExp *)syntaxCopy();
- e->e2 = new DotIdExp(loc, e->e2, ad2->aliasthis->ident);
- return e->trySemantic(sc);
+ Expression *e2 = new DotIdExp(loc, this->e2, ad2->aliasthis->ident);
+ Expression *e = copy();
+ ((BinExp *)e)->e2 = e2;
+ e = e->trySemantic(sc);
+ return e;
}
#endif
return NULL;
|