MyDeveloperDay added a comment.

Here is a potential failure scenario

(test.cpp)

  void *bar();
  
  void foo() {
    void *p;
    int i = 0;
  
    while ((p = bar())) {
      i++;
    }
  }

(.clang-format)

  Language: Cpp
  RemoveParentheses: ReturnStatement



  clang-format test.cpp > test2.cpp



  test2.cpp:7:12: warning: using the result of an assignment as a condition
        without parentheses [-Wparentheses]
    while (p = bar()) {
           ~~^~~~~~~
  test2.cpp:7:12: note: place parentheses around the assignment to silence this
        warning
    while (p = bar()) {
             ^
           (        )
  test2.cpp:7:12: note: use '==' to turn this assignment into an equality
        comparison
    while (p = bar()) {
             ^
             ==
  1 warning generated.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154484/new/

https://reviews.llvm.org/D154484

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to