return state;
BinaryOperator::Opcode op = SE->getOpcode();
- // FIXME: We should implicitly compare non-comparison expressions to 0.
- if (!BinaryOperator::isComparisonOp(op))
- return state;
+ // Implicitly compare non-comparison expressions to 0.
+ if (!BinaryOperator::isComparisonOp(op)) {
+ QualType T = SymMgr.getType(SE);
+ const llvm::APSInt &zero = BasicVals.getValue(0, T);
+ op = (Assumption ? BinaryOperator::NE : BinaryOperator::EQ);
+ return AssumeSymRel(state, SE, op, zero);
+ }
// From here on out, op is the real comparison we'll be testing.
if (!Assumption)
MAKE_TEST_FN() // expected-warning{{null pointer}}
+//===----------------------------------------------------------------------===
+// PR 7491 - Test that symbolic expressions can be used as conditions.
+//===----------------------------------------------------------------------===
+
+void pr7491 () {
+ extern int getint();
+ int a = getint()-1;
+ if (a) {
+ return;
+ }
+ if (!a) {
+ return;
+ } else {
+ // Should be unreachable
+ (void)*(char*)0; // no-warning
+ }
+}
+