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

    <tr>
        <th>Summary</th>
        <td>
            clang gives false positives on overloaded comparison operators in C++
        </td>
    </tr>

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

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

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

<pre>
    clang++ issues a warning when I have an expression like `a >> b > c`:

```
warning: overloaded operator >> has higher precedence than comparison operator [-Woverloaded-shift-op-parentheses]
```

This warning is generated by default, even if I do not put `-Wall`. It is useful for built-in comparison operators, but it generates false positives when I overload my comparison operators for the purpose of doing "expression templates":

https://godbolt.org/z/a4v41qeYz

```
template <Node T, Node U>
Follows<T, U> operator>(T t, U u) { return {t, u}; }

template <Node T, Node U>
FastFollows<T, U> operator>>(T t, U u) { return {t, u}; }
```

I recommend changing the warning so that it does not show up when the return type of the comparison operator is other than `bool`.

This is a practical problem that shows up when using libraries such as Boost.Spirit:

https://godbolt.org/z/EMqGa1zzh
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE1v4zYQ_TX0ZWBDoj5sH3RYJ3GRQ3tpFoseKWokskuRXA7pNPn1BWU7CVKjX4Ah0eJw3gzfmyeI9GQRO9YcWHO_EikqFzrxPbzirMtV74aXThphJ8YPjB9AEyUkEPAsgtV2gmeFFh5BiROCsIB_-IBE2lkw-jsCawsBrHpg1QP0eQGStQWrvrDinhXXZ1tcfsvfS2pWfQF3wmCcGHAA5zGI6MI1mxIESk8KA_iAEge0EiEqYUG62YugydkPp5rD-tt7ujUpPca182svAtqokJBYc3-zoPPzSWl6a1sTTGhzbhygf4EBR5FMZPwO8IQW9AiPMDiwLoJPMd_D-pswhrXFBh5jPp8Ix2RgdAH6pE1c65uVU87Zpwg6vkESjMIQgnekoz4hXWm4Ngjzy81cC1pUCD4F7wjBjTC43BDj_AN3EWdvMhDj_BNZKkZP-Rs_Mn6c3NA7EzcuTIwfXxk_ivpUlz_wt9e_YfiaHlh194sbEJ5yk8vqa6Z3CTo6Y9wzsepu2c0bb43kIL57guXCv0JifA9se4CAMQWbl8tOYtt7Vh0gvz5U8-_gBcV_KuH_VnFLXo8QULp5RjuAVMJOmZVM1VVy5LK6Fx0MDmmRFin3DMmf6c_BF-j44hdu86db06AJXMyjs8wLa4veuUWbfxG8zsPug5BRS2HAB9cbnM-VZHR6g0-UqzS6DyJoJKAkFQiCg3MUN796HXT8j1p6-PnHT6J8fVWroauGfbUXK-zKbdHu26pu65Xq6r6sJMe-2G0rLnizLRspZMPrvRgH2e5WuuMFrwteVCWvyqLeDIPYl20z7uSW72SzY3WBs9BmY8xpztirxeO6XdFUu5URPRpa7JHzixHy7JShy_HrPk3E6sJoivSeIepo8OybMC3z-XleMxnv3nZzVLWFu7PrrlIw3ae70lGlfiPdzPgx415eax_c7ygj48ezVTN-XDr5MwAA___GSuHV">