<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Improve -Wparentheses for arbitrary bool contexts"
   href="https://bugs.llvm.org/show_bug.cgi?id=34180">34180</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Improve -Wparentheses for arbitrary bool contexts
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>chisophugis@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre><a href="https://godbolt.org/g/Ca2Xtv">https://godbolt.org/g/Ca2Xtv</a>

bool f(int x) {
    return x = 0; 
}


GCC gives:

<source>:2:16: warning: suggest parentheses around assignment used as truth
value [-Wparentheses]
     return x = 0; 
                ^

This would have caught a bug in r310794 (<a href="https://reviews.llvm.org/rL310794">https://reviews.llvm.org/rL310794</a>)

I don't know for sure, but from the reduced test case, it seems that GCC is
just seeing when an assignment is used in a bool-typed context? E.g. just
`bool(x = 0)` seems to trigger it. <a href="https://godbolt.org/g/HyBZHM">https://godbolt.org/g/HyBZHM</a>
Looking at the two examples, it looks like ImplicitCastExpr to bool is probably
the thing to look for.
ImplicitCastExpr 0x4fce318 <col:12, col:16> '_Bool' <IntegralToBoolean>
ImplicitCastExpr 0x4fce578 <col:17, col:21> '_Bool' <IntegralToBoolean></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>