<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/76359>76359</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            -Wcomma is emmitted for assignments from function return values, even when the result is used as a comparison
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jpcregan
      </td>
    </tr>
</table>

<pre>
    Hello,

My code triggered -Wcomma and upon some research I came across this issue: https://github.com/llvm/llvm-project/issues/57151

It references https://reviews.llvm.org/D3976 which states

> The current whitelisted expressions are increments, decrements, assignments, compound assignments, overloaded versions of these operators, and void returning functions

[Here](https://godbolt.org/z/frh5MorYP) is an example which triggers the warning.
```
#include <stdio.h>

int main (void)
{
    int c;

    while (c = fgetc(stdin), c != EOF)
 {

    }

    return 0;
}
```

While not strictly a pure assignment, I think the intention is clear and I don't consider it misuse.
Changing the statement to `while ((c = fgetc(stdin)) != EOF)` is functionally identical and does not trigger the warning, but I find it more difficult to read.

Could we add an exception where if the result of a function is used later in the comma it doesn't trigger the warning?

Thanks,

Jordan
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyclEGPozgQhX-NuZQmAjOE5sChO-lostJo9zDSaI-OXYBnjI3KJpneX7-yodNstNrDShEJYD-_-qryhPe6t4gtq15YdczEHAZH7Y9JEvbCZhen3tovaIxj_MDyI8ufl-vXN5BOIQTSfY-ECj59l24cBQirYJ6cBe9GBEKPguQAZ5BiRBCSnPcQBu1Bez8jK59hCGHyrHxm_MT4qddhmC876UbGT8Zc378-TeR-oAyMn9JOz_ipqouq2Po6ByDskNBK9A_ChFeNN7-LYjtHPeOnY9nUe7gNWg7ggwjot2KsfIVvA4KcidCGuC6g0T6gAvw1EXqvnfUgCEFbSTiiDZ7xAyjc3i2U77fSjZObrXp87q5IxgmFCq5Ii7TrIAzoE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