[PATCH] D47687: [Sema] Missing -Wlogical-op-parentheses warnings in macros (PR18971)
Volodymyr Sapsai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 6 18:14:19 PST 2018
vsapsai added a comment.
OK. Good to know you are still working on it.
In https://reviews.llvm.org/D47687#1271880, @Higuoxing wrote:
> In https://reviews.llvm.org/D47687#1266893, @vsapsai wrote:
>
> > Sorry about the delay. The change seems to be correct but `ninja check-clang` reveals the test "Misc/caret-diags-macros.c" is failing. Can you please look into that?
>
>
> Hi, It's because the expression is given in multiple lines and my `SuggestParentheses` cannot give proper fix-it hint. But I could give proper `ParenRange` in macros. Shall we reserve current `SuggestParentheses` and just give Parenrange hit in macros ? I have no idea about this ...
Why is the expression on multiple lines in this case? I didn't check in debugger but the test case looks like you can place `)` between `BAD_CONDITIONAL_OPERATOR` and `;`. At least that's what I would expect as compiler user.
llvm-project/clang/test/Misc/caret-diags-macros.c:125:38: warning: operator '?:' has lower precedence than '+'; '+' will be evaluated first
int test4 = BAD_CONDITIONAL_OPERATOR+BAD_CONDITIONAL_OPERATOR;
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
llvm-project/clang/test/Misc/caret-diags-macros.c:124:39: note: expanded from macro 'BAD_CONDITIONAL_OPERATOR'
#define BAD_CONDITIONAL_OPERATOR (2<3)?2:3
^
llvm-project/clang/test/Misc/caret-diags-macros.c:125:38: note: place parentheses around the '+' expression to silence this warning
llvm-project/clang/test/Misc/caret-diags-macros.c:124:39: note: expanded from macro 'BAD_CONDITIONAL_OPERATOR'
#define BAD_CONDITIONAL_OPERATOR (2<3)?2:3
^
llvm-project/clang/test/Misc/caret-diags-macros.c:125:38: note: place parentheses around the '?:' expression to evaluate it first
int test4 = BAD_CONDITIONAL_OPERATOR+BAD_CONDITIONAL_OPERATOR;
^
(
llvm-project/clang/test/Misc/caret-diags-macros.c:124:39: note: expanded from macro 'BAD_CONDITIONAL_OPERATOR'
#define BAD_CONDITIONAL_OPERATOR (2<3)?2:3
^
https://reviews.llvm.org/D47687
More information about the cfe-commits
mailing list