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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] `-Wparentheses-equality` produces a false positive for `==` fold expressions in conditions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend
      </td>
    </tr>

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

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

<pre>
    The following code (https://godbolt.org/z/rPqP4r55b):
```c++
void foo(auto... args) {
    if (((args == 0) or ...)) {}
}

void f() { 
    foo(3);
}
```
results in a `-Wparentheses-equality` warning:
```
<source>:2:16: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
    2 |     if (((args == 0) or ...)) {}
      |           ~~~~~^~~~
<source>:6:5: note: in instantiation of function template specialization 'foo<int>' requested here
    6 |     foo(3);
      |     ^
<source>:2:16: note: remove extraneous parentheses around the comparison to silence this warning
    2 |     if (((args == 0) or ...)) {}
      |          ~     ^ ~
<source>:2:16: note: use '=' to turn this equality comparison into an assignment
    2 |     if (((args == 0) or ...)) {}
      | ^~
      |                =
```
However, the suggestion to remove parentheses here is obviously wrong: neither pair of parentheses can be removed, as that would result in an invalid fold expression (because `args == 0` is not a cast-expression). It seems that, generally speaking, we should not issue this warning if the equality comparison is the operand of a fold expression.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VU2P4jgQ_TXmUiIyNknIIQcaGu3eRtqV9uwklcS7xk7bDkzPYX77qhJo6B56VxppIot8UB_v1Su7VAi6s4glS59Yul-oMfbOl39o75VucFG55rX8s0donTHurG0HtWsQmNj0MQ6ByS0TByYOnWsqZ2LifMfE4RsTB__l5cvap2nFREFmfM_4lmV8XjUTT7SmryenG2idY2KjxuiSJAHlu8BEASy_2AAA6JYSz4sMgMk9k3vgZOk8JElCyS5u-f6S8-3hLtkUZL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