[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression
NagaChaitanya Vellanki via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 25 17:29:10 PDT 2023
chaitanyav added a comment.
In D147844#4293299 <https://reviews.llvm.org/D147844#4293299>, @cjdb wrote:
> 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.
@cjb quick question, should we restrict to
>, <, >=, <=
I am finding lots of files in the project with ` ==` and `?:` precedence warnings.
================
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}}
----------------
cjdb wrote:
> I think this should also warn.
@cjdb am looking into this.
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