From 0e33c688d519bffe80ef2b45a5c7107ebaf7d9cf Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Wed, 19 Nov 2008 17:44:31 +0000 Subject: [PATCH] fix folding of '*doubleArray' llvm-svn: 59647 --- clang/lib/AST/ExprConstant.cpp | 3 +++ clang/test/CodeGen/exprs.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index ef8e2d4c1305..6b71d1100438 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -972,6 +972,9 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) { } bool FloatExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) { + if (E->getOpcode() == UnaryOperator::Deref) + return false; + if (!EvaluateFloat(E->getSubExpr(), Result, Info)) return false; diff --git a/clang/test/CodeGen/exprs.c b/clang/test/CodeGen/exprs.c index 275c988ab9bd..07a9158744bc 100644 --- a/clang/test/CodeGen/exprs.c +++ b/clang/test/CodeGen/exprs.c @@ -45,3 +45,10 @@ int ola() { if ((0, (int)a) & 2) { return 1; } return 2; } + +// this one shouldn't fold as well +void eMaisUma() { + double t[1]; + if (*t) + return; +}