aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/warn-unused-value.c
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-06-30 10:53:14 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-06-30 10:53:14 +0000
commit25973455aed1cdc9c40b208c792b5db4f8f1297d (patch)
tree7fc5f12a8716c208d2fdb8663464665c8c2421f8 /test/Sema/warn-unused-value.c
parent8f4eae96bef0902d93535c18b69154ce66f5e546 (diff)
Fix rdar://8139785 "implement warning on dead expression in comma operator"
As a bonus, fix the warning for || and && operators; it was emitted even if one of the operands had side effects, e.g: x || test_logical_foo1(); emitted a bogus "expression result unused" for 'x'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107274 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/warn-unused-value.c')
-rw-r--r--test/Sema/warn-unused-value.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/test/Sema/warn-unused-value.c b/test/Sema/warn-unused-value.c
index 16b787f774..1a7e745785 100644
--- a/test/Sema/warn-unused-value.c
+++ b/test/Sema/warn-unused-value.c
@@ -18,9 +18,9 @@ void pr4806() {
i,foo(); // expected-warning {{expression result unused}}
foo(),i; // expected-warning {{expression result unused}}
- i,j,foo(); // expected-warning {{expression result unused}}
- i,foo(),j; // expected-warning {{expression result unused}}
- foo(),i,j; // expected-warning {{expression result unused}}
+ i,j,foo(); // expected-warning {{expression result unused}} expected-warning {{expression result unused}}
+ i,foo(),j; // expected-warning {{expression result unused}} expected-warning {{expression result unused}}
+ foo(),i,j; // expected-warning {{expression result unused}} expected-warning {{expression result unused}}
i++;
@@ -63,6 +63,16 @@ int test_logical_bar() {
(x = test_logical_foo1()) || // no-warning
(x = test_logical_foo2()) || // no-warning
(x = test_logical_foo3()); // no-warning
+
+ x || test_logical_foo1(); // no-warning
+
return x;
}
+struct s0 { int f0; };
+
+void f0(int a);
+void f1(struct s0 *a) {
+ // rdar://8139785
+ f0((int)(a->f0 + 1, 10)); // expected-warning {{expression result unused}}
+}