return IsLogicOp(OP->getOpcode());
if (UnaryOperator *OP = dyn_cast<UnaryOperator>(E))
return OP->getOpcode() == UO_LNot;
+ if (E->getType()->isPointerType())
+ return true;
return false;
}
_Bool someConditionFunc();
-void conditional_op(int x, int y, _Bool b) {
+void conditional_op(int x, int y, _Bool b, void* p) {
(void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} \
// expected-note {{place parentheses around the '+' expression to silence this warning}} \
// expected-note {{place parentheses around the '?:' expression to evaluate it first}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:24-[[@LINE-6]]:24}:")"
(void)(x % 2 ? 1 : 2); // no warning
+
+ (void)(x + p ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} expected-note 2{{place parentheses}}
+ (void)(p + x ? 1 : 2); // no warning
+
+ (void)(p + b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} expected-note 2{{place parentheses}}
+
+ (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}}
}
// RUN: not %clang_cc1 -fsyntax-only -Wparentheses -Werror -fdiagnostics-show-option %s 2>&1 | FileCheck %s -check-prefix=CHECK-FLAG