diff options
author | John McCall <rjmccall@apple.com> | 2011-02-26 08:27:17 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-02-26 08:27:17 +0000 |
commit | 3b332ab132fa85c83833d74d400f6e126f52fbd2 (patch) | |
tree | 6c6a6d685c8b86cfa0b439b57d81dfa59d08d049 | |
parent | bc7fbf0d37b286b37d96b033dfaaabf9c729bca8 (diff) |
Don't crash during constant-evaluation of 1/(1/0). PR9262.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126541 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/ExprConstant.cpp | 2 | ||||
-rw-r--r-- | test/Sema/i-c-e.c | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 656bb99df9..3a5eb66ea1 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -2926,7 +2926,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { Exp->getOpcode() == BO_Rem) { // Evaluate gives an error for undefined Div/Rem, so make sure // we don't evaluate one. - if (LHSResult.Val != 2 && RHSResult.Val != 2) { + if (LHSResult.Val == 0 && RHSResult.Val == 0) { llvm::APSInt REval = Exp->getRHS()->EvaluateAsInt(Ctx); if (REval == 0) return ICEDiag(1, E->getLocStart()); diff --git a/test/Sema/i-c-e.c b/test/Sema/i-c-e.c index d0a6c529c1..4d7007cd07 100644 --- a/test/Sema/i-c-e.c +++ b/test/Sema/i-c-e.c @@ -66,6 +66,8 @@ int illegaldiv1b[1 && 1/0]; // expected-warning {{division by zero is undefined int illegaldiv2[1/0]; // expected-error {{variable length array declaration not allowed at file scope}} \ // expected-warning {{division by zero is undefined}} int illegaldiv3[INT_MIN / -1]; // expected-error {{variable length array declaration not allowed at file scope}} +// PR9262 +int illegaldiv4[0 / (1 / 0)]; // expected-warning {{division by zero is undefined}} expected-error {{variable length array declaration not allowed at file scope}} int chooseexpr[__builtin_choose_expr(1, 1, expr)]; int realop[(__real__ 4) == 4 ? 1 : -1]; |