--- Comment #12 from Don <> 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.

   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 ==
        return e1->checkSideEffect(flag);

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to