diff options
author | dim <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
commit | c49018d9cce52d8c9f34b44865ec3ba8e89a1488 (patch) | |
tree | c5e9e10bc189de0058aa763c47b9920a8351b7df /test/Sema/parentheses.c | |
parent | 110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab (diff) | |
download | FreeBSD-src-c49018d9cce52d8c9f34b44865ec3ba8e89a1488.zip FreeBSD-src-c49018d9cce52d8c9f34b44865ec3ba8e89a1488.tar.gz |
Vendor import of clang trunk r132879:
http://llvm.org/svn/llvm-project/cfe/trunk@132879
Diffstat (limited to 'test/Sema/parentheses.c')
-rw-r--r-- | test/Sema/parentheses.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/test/Sema/parentheses.c b/test/Sema/parentheses.c index a25ded6..fa3c3c2 100644 --- a/test/Sema/parentheses.c +++ b/test/Sema/parentheses.c @@ -39,6 +39,28 @@ void bitwise_rel(unsigned i) { (void)(0 || i && i); // no warning. } +_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}} + + (void)(x / !x ? 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 % 2 ? 1 : 2); // no warning +} + // RUN: %clang_cc1 -fsyntax-only -Wparentheses -Werror -fdiagnostics-show-option %s 2>&1 | FileCheck %s // CHECK: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses] - |