Don't emit an 'unused expression' warning for '||' and '&&' expressions that contain assignments
or similar side-effects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100676 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/warn-unused-value.c b/test/Sema/warn-unused-value.c
index 2e0fa54..cc8a848 100644
--- a/test/Sema/warn-unused-value.c
+++ b/test/Sema/warn-unused-value.c
@@ -51,3 +51,16 @@
*pi; // expected-warning {{expression result unused}}
*pj;
}
+
+// Don't warn about unused '||', '&&' expressions that contain assignments.
+int test_logical_foo1();
+int test_logical_foo2();
+int test_logical_foo3();
+int test_logical_bar() {
+ int x = 0;
+ (x = test_logical_foo1()) || // no-warning
+ (x = test_logical_foo2()) || // no-warning
+ (x = test_logical_foo3()); // no-warning
+ return x;
+}
+