blob: ad1f399c6496a38f8cbf4b02f91012625c061d26 [file] [log] [blame]
Hans Wennborg9cfdae32011-06-03 18:00:36 +00001// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
2// RUN: %clang_cc1 -Wparentheses -fixit %s -o - | %clang_cc1 -Wparentheses -Werror -
3
4bool someConditionFunc();
5
6void conditional_op(int x, int y, bool b) {
7 (void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{?: has lower precedence than +}} \
8 // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
9 // expected-note {{place parentheses around the + expression to silence this warning}}
10
11 (void)(x - b ? 1 : 2); // expected-warning {{?: has lower precedence than -}} \
12 // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
13 // expected-note {{place parentheses around the - expression to silence this warning}}
14
15 (void)(x * (x == y) ? 1 : 2); // expected-warning {{?: has lower precedence than *}} \
16 // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
17 // expected-note {{place parentheses around the * expression to silence this warning}}
18}