summaryrefslogtreecommitdiff
path: root/test/Sema/parentheses.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2011-07-17 15:40:56 +0000
committerDimitry Andric <dim@FreeBSD.org>2011-07-17 15:40:56 +0000
commit180abc3db9ae3b4fc63cd65b15697e6ffcc8a657 (patch)
tree2097d084eb235c0b12c0bff3445f4ec7bbaa8a12 /test/Sema/parentheses.cpp
parent29cafa66ad3878dbb9f82615f19fa0bded2e443c (diff)
downloadsrc-test2-180abc3db9ae3b4fc63cd65b15697e6ffcc8a657.tar.gz
src-test2-180abc3db9ae3b4fc63cd65b15697e6ffcc8a657.zip
Notes
Diffstat (limited to 'test/Sema/parentheses.cpp')
-rw-r--r--test/Sema/parentheses.cpp38
1 files changed, 26 insertions, 12 deletions
diff --git a/test/Sema/parentheses.cpp b/test/Sema/parentheses.cpp
index a25f2a0ce7b8..252455dcad49 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");
}