[Issue 4231] Solitary opUnary Postincrement and Postdecrement user defined operators are broken.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 8 00:01:24 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4231
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #10 from Don <clugdbug at yahoo.com.au> 2010-06-08 00:01:20 PDT ---
This patch only stops the side effect message, it doesn't turn x++; into ++x;
Note that this patch deals with more difficult cases such as:
struct Foo{
int opUnary(string op)() { return 1; }
}
void main() {
Foo foo;
int w;
++w, foo++;
}
----
Index: expression.c
===================================================================
--- expression.c (revision 526)
+++ expression.c (working copy)
@@ -8520,6 +8520,14 @@
int CommaExp::checkSideEffect(int flag)
{
+ // Check for compiler-generated code of the form auto __tmp, e, __tmp;
+ // In such cases, only check e for side effect (it's OK for __tmp to have
no side effect).
+ CommaExp * firstComma = this;
+ while (firstComma->e1->op == TOKcomma)
+ firstComma = (CommaExp *)firstComma->e1;
+ if (firstComma->e1->op == TOKdeclaration && e2->op == TOKvar)
+ return e1->checkSideEffect(flag);
+
if (flag == 2)
return e1->checkSideEffect(2) || e2->checkSideEffect(2);
else
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list