summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-02-26 08:27:17 +0000
committerJohn McCall <rjmccall@apple.com>2011-02-26 08:27:17 +0000
commit4b13633082f523b91b0eeee92cafe9f7958e6cec (patch)
tree48a2ad841c6eb5bd250bc1be82e31b64ca22ee20 /clang
parent53fcbd2718222d3c2abef0a39cf7bb73f2d63b8f (diff)
downloadbcm5719-llvm-4b13633082f523b91b0eeee92cafe9f7958e6cec.tar.gz
bcm5719-llvm-4b13633082f523b91b0eeee92cafe9f7958e6cec.zip
Don't crash during constant-evaluation of 1/(1/0). PR9262.
llvm-svn: 126541
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/ExprConstant.cpp2
-rw-r--r--clang/test/Sema/i-c-e.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 656bb99df98..3a5eb66ea18 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/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/clang/test/Sema/i-c-e.c b/clang/test/Sema/i-c-e.c
index d0a6c529c16..4d7007cd077 100644
--- a/clang/test/Sema/i-c-e.c
+++ b/clang/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];
OpenPOWER on IntegriCloud