[cfe-dev] asserts
John Thompson
john.thompson.jtsoftware at gmail.com
Wed Apr 21 15:35:36 PDT 2010
I'm getting a couple of asserts, one from the assert in
Sema::ActOnNumericConstant at line 1897, the other in a separate case in the
APInt::trunc call because the argument is bigger than the width.
These two changes seem to avoid the asserts, I'm not sure it's the right
fix:
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp (revision 102026)
+++ lib/Sema/SemaExpr.cpp (working copy)
@@ -1885,7 +1885,10 @@
Diag(Tok.getLocation(), diag::ext_longlong);
// Get the value in the widest-possible width.
- llvm::APInt ResultVal(Context.Target.getIntMaxTWidth(), 0);
+ llvm::APInt ResultVal(
+ Literal.isLongLong ?
+ Context.Target.getLongLongWidth() :
+ Context.Target.getIntMaxTWidth(), 0);
if (Literal.GetIntegerValue(ResultVal)) {
// If this value didn't fit into uintmax_t, warn and force to ull.
@@ -1956,8 +1959,12 @@
Width = Context.Target.getLongLongWidth();
}
- if (ResultVal.getBitWidth() != Width)
- ResultVal.trunc(Width);
+ if (ResultVal.getBitWidth() != Width) {
+ if (Literal.isUnsigned)
+ ResultVal.zextOrTrunc(Width);
+ else
+ ResultVal.sextOrTrunc(Width);
+ }
}
Res = new (Context) IntegerLiteral(ResultVal, Ty, Tok.getLocation());
}
--
John Thompson
John.Thompson.JTSoftware at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100421/72d006eb/attachment.html>
More information about the cfe-dev
mailing list