[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

Christopher Di Bella via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 24 12:27:30 PDT 2023


cjdb added a comment.

I think this is a good diagnostic to add: it improves readability and eliminates ambiguities. My only request is that if there isn't already a FixIt hint, one be added, please.



================
Comment at: clang/test/Sema/parentheses.c:94
 
   (void)(x + y > 0 ? 1 : 2); // no warning
   (void)(x + (y > 0) ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} expected-note 2{{place parentheses}}
----------------
I think this should also warn.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844



More information about the cfe-commits mailing list