if (init == lastLoad) {
DeclRefExpr *DR =
cast<DeclRefExpr>(lastLoad->getSubExpr()->IgnoreParens());
- vals[vd] = (DR->getDecl() == vd) ? Uninitialized : Initialized;
- lastLoad = 0;
- if (lastDR == DR)
+ if (DR->getDecl() == vd) {
+ // int x = x;
+ // Propagate uninitialized value, but don't immediately report
+ // a problem.
+ vals[vd] = Uninitialized;
+ lastLoad = 0;
lastDR = 0;
+ return;
+ }
}
- else {
- vals[vd] = Initialized;
- }
+
+ // All other cases: treat the new variable as initialized.
+ vals[vd] = Initialized;
}
}
}
}
void test53() {
- int x;
- int y = (x);
+ int x; // expected-note {{variable 'x' is declared here}} expected-note {{add initialization to silence this warning}}
+ int y = (x); // expected-warning {{variable 'x' is uninitialized when used here}}
}
// This CFG caused the uninitialized values warning to inf-loop.