[cfe-commits] r126541 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/Sema/i-c-e.c
John McCall
rjmccall at apple.com
Sat Feb 26 00:27:17 PST 2011
Author: rjmccall
Date: Sat Feb 26 02:27:17 2011
New Revision: 126541
URL: http://llvm.org/viewvc/llvm-project?rev=126541&view=rev
Log:
Don't crash during constant-evaluation of 1/(1/0). PR9262.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/Sema/i-c-e.c
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=126541&r1=126540&r2=126541&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sat Feb 26 02:27:17 2011
@@ -2926,7 +2926,7 @@
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());
Modified: cfe/trunk/test/Sema/i-c-e.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/i-c-e.c?rev=126541&r1=126540&r2=126541&view=diff
==============================================================================
--- cfe/trunk/test/Sema/i-c-e.c (original)
+++ cfe/trunk/test/Sema/i-c-e.c Sat Feb 26 02:27:17 2011
@@ -66,6 +66,8 @@
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];
More information about the cfe-commits
mailing list