[PATCH] D13643: [Sema] Warn on ternary comparison

Matěj Grabovský via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 18 22:55:08 PDT 2015


mgrabovsky added a comment.

In http://reviews.llvm.org/D13643#266926, @aaron.ballman wrote:

> I would spend some time digging into how GCC handles those cases, and use that as a baseline that we can then improve upon. I like the fact that GCC basically says "use parens to clarify your intent", as that solves all of the cases regarding equality and inequality.
>
> I would imagine type == type == bool should behave the same as bool == bool == bool; it can be valid code that just needs parens to clarify intent. As for C90 behavior, I'm not too worried about what we do there.


I'm back. The warning is emitted in `gcc/c-family/c-common.c` L11488–11503; GCC only does this for what LLVM calls 'relational' operators (i.e., comparisons except == and !=) and for integral types.


http://reviews.llvm.org/D13643





More information about the cfe-commits mailing list