diff options
| author | Ted Kremenek <kremenek@apple.com> | 2011-03-01 20:34:48 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2011-03-01 20:34:48 +0000 |
| commit | e96dad9544f0f87dc65ba097f4fb05b25a3fb804 (patch) | |
| tree | 2f344c42ac8a51b64b1b85891d0e8773a08a7632 /clang/test | |
| parent | a7a795bed1fd104b162add53a8ab15e163f6648f (diff) | |
| download | bcm5719-llvm-e96dad9544f0f87dc65ba097f4fb05b25a3fb804.tar.gz bcm5719-llvm-e96dad9544f0f87dc65ba097f4fb05b25a3fb804.zip | |
Don't warn about unused values in ternary ?: expressions unless both the LHS and RHS are "unused" (side-effect free).
Patch by Justin Bogner! Fixes PR 8282.
llvm-svn: 126779
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Sema/warn-unused-value.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/test/Sema/warn-unused-value.c b/clang/test/Sema/warn-unused-value.c index 876eb9e4823..95cd8fb7040 100644 --- a/clang/test/Sema/warn-unused-value.c +++ b/clang/test/Sema/warn-unused-value.c @@ -72,6 +72,15 @@ int test_logical_bar() { return x; } +// PR8282 +void conditional_for_control_flow(int cond, int x, int y) +{ + cond? y++ : x; // no-warning + cond? y : ++x; // no-warning + cond? (x |= y) : ++x; // no-warning + cond? y : x; // expected-warning {{expression result unused}} +} + struct s0 { int f0; }; void f0(int a); |

