diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
| commit | 29cafa66ad3878dbb9f82615f19fa0bded2e443c (patch) | |
| tree | c5e9e10bc189de0058aa763c47b9920a8351b7df /test/Sema/parentheses.cpp | |
| parent | 01af97d3b23bded2b2b21af19bbc6e4cce49e5b3 (diff) | |
Vendor import of clang trunk r132879:vendor/clang/clang-r132879
Notes
svn path=/vendor/clang/dist/; revision=223015
svn path=/vendor/clang/clang-r132879/; revision=223016; tag=vendor/clang/clang-r132879
Diffstat (limited to 'test/Sema/parentheses.cpp')
| -rw-r--r-- | test/Sema/parentheses.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/Sema/parentheses.cpp b/test/Sema/parentheses.cpp new file mode 100644 index 000000000000..a25f2a0ce7b8 --- /dev/null +++ b/test/Sema/parentheses.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s +// RUN: %clang_cc1 -Wparentheses -fixit %s -o - | %clang_cc1 -Wparentheses -Werror - + +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 - 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 * (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}} +} + +class Stream { +public: + operator int(); + Stream &operator<<(int); + Stream &operator<<(const char*); +}; + +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}} +} |
