http://d.puremagic.com/issues/show_bug.cgi?id=4231



--- Comment #12 from Don <clugd...@yahoo.com.au> 2010-06-08 01:22:02 PDT ---
(In reply to comment #11)
> Hrm.. I haven't studied the side effect code enough.  Do you know why
> Comma:Exp::checkSideEffect isn't just:
> 
> return e1->checkSideEffect(flag) || e2->checkSideEffect(flag)
> 
> ie, no conditional.

If flag isn't 2, you still want to check for a useless subexpression.

Eg.
   int x;
   int y;
   ++y, x;
This should still be an error, since x; has no effect.

This shows me that my patch isn't quite right, it will erroneously allow

void main() {
    Foo foo;
    int w;
    foo++, w;
}

--
Revised patch (added one line): should ensure that the created variable is the
same as the one which is returned.

    CommaExp * firstComma = this;
    while (firstComma->e1->op == TOKcomma)
        firstComma = (CommaExp *)firstComma->e1;
    if (firstComma->e1->op == TOKdeclaration && e2->op == TOKvar
+        && ((DeclarationExp *)firstComma->e1)->declaration ==
((VarExp*)e2)->var)
        return e1->checkSideEffect(flag);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to