summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/misc-ps.c
diff options
context:
space:
mode:
authorJordy Rose <jediknil@belkadan.com>2011-06-10 08:49:37 +0000
committerJordy Rose <jediknil@belkadan.com>2011-06-10 08:49:37 +0000
commit1734737d9f9ebeb7938a1c66be75374da63cabcd (patch)
treee76b8d8692d058ec011d57cf4a235527313a6a1d /clang/test/Analysis/misc-ps.c
parent82818e4d9525a396cc08a321a62c1538cf56d003 (diff)
downloadbcm5719-llvm-1734737d9f9ebeb7938a1c66be75374da63cabcd.tar.gz
bcm5719-llvm-1734737d9f9ebeb7938a1c66be75374da63cabcd.zip
[analyzer] PR8962 again. Ban ParenExprs (and friends) from block-level expressions (by calling IgnoreParens before adding expressions to blocks). Undo 132769 (LiveVariables' local IgnoreParens), since it's no longer necessary.
Also, have Environment stop looking through NoOp casts; it didn't match the behavior of LiveVariables. And once that's gone, the whole cast block of that switch is unnecessary. llvm-svn: 132840
Diffstat (limited to 'clang/test/Analysis/misc-ps.c')
-rw-r--r--clang/test/Analysis/misc-ps.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/test/Analysis/misc-ps.c b/clang/test/Analysis/misc-ps.c
index 84992c6bb25..bef5b061818 100644
--- a/clang/test/Analysis/misc-ps.c
+++ b/clang/test/Analysis/misc-ps.c
@@ -62,3 +62,22 @@ int PR8962_d (int *t) {
return *t; // no-warning
}
+int PR8962_e (int *t) {
+ // Redundant casts can mess things up!
+ // Environment used to skip through NoOp casts, but LiveVariables didn't!
+ if (({ (t ? (int)(int)0L : (int)(int)1L); })) return 0;
+ return *t; // no-warning
+}
+
+int PR8962_f (int *t) {
+ // The StmtExpr isn't a block-level expression here,
+ // the __extension__ is. But the value should be attached to the StmtExpr
+ // anyway. Make sure the block-level check is /before/ IgnoreParens.
+ if ( __extension__({
+ _Bool r;
+ if (t) r = 0;
+ else r = 1;
+ r;
+ }) ) return 0;
+ return *t; // no-warning
+}
OpenPOWER on IntegriCloud