diff options
Diffstat (limited to 'test/Sema/parentheses.cpp')
-rw-r--r-- | test/Sema/parentheses.cpp | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/test/Sema/parentheses.cpp b/test/Sema/parentheses.cpp index a25f2a0..252455d 100644 --- a/test/Sema/parentheses.cpp +++ b/test/Sema/parentheses.cpp @@ -4,17 +4,17 @@ bool someConditionFunc(); void conditional_op(int x, int y, bool b) { - (void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{?: has lower precedence than +}} \ - // expected-note {{place parentheses around the ?: expression to evaluate it first}} \ - // expected-note {{place parentheses around the + expression to silence this warning}} + (void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ + // expected-note {{place parentheses around the '+' expression to silence this warning}} - (void)(x - b ? 1 : 2); // expected-warning {{?: has lower precedence than -}} \ - // expected-note {{place parentheses around the ?: expression to evaluate it first}} \ - // expected-note {{place parentheses around the - expression to silence this warning}} + (void)(x - b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '-'}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ + // expected-note {{place parentheses around the '-' expression to silence this warning}} - (void)(x * (x == y) ? 1 : 2); // expected-warning {{?: has lower precedence than *}} \ - // expected-note {{place parentheses around the ?: expression to evaluate it first}} \ - // expected-note {{place parentheses around the * expression to silence this warning}} + (void)(x * (x == y) ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '*'}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ + // expected-note {{place parentheses around the '*' expression to silence this warning}} } class Stream { @@ -25,7 +25,21 @@ public: }; void f(Stream& s, bool b) { - (void)(s << b ? "foo" : "bar"); // expected-warning {{?: has lower precedence than <<}} \ - // expected-note {{place parentheses around the ?: expression to evaluate it first}} \ - // expected-note {{place parentheses around the << expression to silence this warning}} + (void)(s << b ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '<<'}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ + // expected-note {{place parentheses around the '<<' expression to silence this warning}} +} + +struct S { + operator int() { return 42; } + friend S operator+(const S &lhs, bool) { return S(); } +}; + +void test(S *s, bool (S::*m_ptr)()) { + (void)(*s + true ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '+'}} \ + // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \ + // expected-note {{place parentheses around the '+' expression to silence this warning}} + + // Don't crash on unusual member call expressions. + (void)((s->*m_ptr)() ? "foo" : "bar"); } |