[cfe-dev] asserts
Chris Lattner
clattner at apple.com
Wed Apr 28 13:20:55 PDT 2010
On Apr 21, 2010, at 3:35 PM, John Thompson wrote:
> 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.
Hi John,
I don't understand why this is a bug, can you give a testcase?
>
> 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
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100428/6ec5a99b/attachment.html>
More information about the cfe-dev
mailing list