[PATCH] new check checking use of identical expressions inside a conditional expression, i.e. '?'.
Jordan Rose
jordan_rose at apple.com
Wed Nov 20 09:22:16 PST 2013
Hm, interesting. In this case:
+void test_expr_negative_func() {
+ unsigned a = 0;
+ unsigned b = 1;
+ a = a > 5 ? a+func() : a+func(); // no warning
+}
I think we should actually be warning, since only one side of the branch will ever be executing. Maybe we can include a flag here that says whether the expression walker should step into calls? What do you think?
Other than that, this looks good, except that I would add the true-expr and false-expr as ranges to highlight in addition to putting the warning itself on the colon.
Jordan
More information about the cfe-commits
mailing list