<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - No -Wparentheses warning for "if (a += b)""
   href="http://llvm.org/bugs/show_bug.cgi?id=19063">19063</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>No -Wparentheses warning for "if (a += b)"
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </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>chengniansun@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The clang trunk emits -Wparentheses warnings for "if (a |= b)" and "if(a = a +
b)", but not "if (a += b)"



$: cat s.c 
int b;
int f(int a) {
  if (a |= b)
    return 3;
  else if (a += b) /* <- no warning here*/ 
    return 2;
  else if (a = a + b) 
    return 4;
  else 
    return 1;
}
$: clang-trunk -Wparentheses -c s.c
s.c:3:9: warning: using the result of an assignment as a condition without
parentheses [-Wparentheses]
  if (a |= b)
      ~~^~~~
s.c:3:9: note: place parentheses around the assignment to silence this warning
  if (a |= b)
        ^
      (     )
s.c:3:9: note: use '!=' to turn this compound assignment into an inequality
comparison
  if (a |= b)
        ^~
        !=
s.c:7:14: warning: using the result of an assignment as a condition without
parentheses [-Wparentheses]
  else if (a = a + b) 
           ~~^~~~~~~
s.c:7:14: note: place parentheses around the assignment to silence this warning
  else if (a = a + b) 
             ^
           (        )
s.c:7:14: note: use '==' to turn this assignment into an equality comparison
  else if (a = a + b) 
             ^
             ==
2 warnings generated.
$:</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>