[cfe-commits] r69046 - /cfe/trunk/lib/Lex/LiteralSupport.cpp
Chris Lattner
clattner at apple.com
Tue Apr 14 10:16:01 PDT 2009
On Apr 14, 2009, at 9:46 AM, Sanjiv Gupta wrote:
> Author: sgupta
> Date: Tue Apr 14 11:46:37 2009
> New Revision: 69046
>
> URL: http://llvm.org/viewvc/llvm-project?rev=69046&view=rev
> Log:
> Literal value calculation isn't likely to overflow on targets having
> int as 32 or less. Fixing the assert as it otherwise triggers for
> PIC16 which as i16 as int.
Sanjiv, this isn't correct. If 'int' is 16 bits, then 'abc' should
produce the warn_char_constant_too_large warning. This won't happen
because the overflow check is:
if (((Value << 8) >> 8) != Value)
PP.Diag(Loc, diag::warn_char_constant_too_large);
and "Value" has 32-bits. That was why the assertion existed.
-Chris
>
>
> Modified:
> cfe/trunk/lib/Lex/LiteralSupport.cpp
>
> Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=69046&r1=69045&r2=69046&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
> +++ cfe/trunk/lib/Lex/LiteralSupport.cpp Tue Apr 14 11:46:37 2009
> @@ -632,10 +632,10 @@
> assert(begin[0] == '\'' && "Invalid token lexed");
> ++begin;
>
> - // FIXME: This assumes that 'int' is 32-bits in overflow
> calculation, and the
> - // size of "value".
> - assert(PP.getTargetInfo().getIntWidth() == 32 &&
> - "Assumes sizeof(int) == 4 for now");
> + // FIXME: This assumes that 'int' is not more than 32-bits in
> overflow
> + // calculation, and the size of "value".
> + assert(PP.getTargetInfo().getIntWidth() <= 32 &&
> + "Assumes sizeof(int) <= 4 for now");
> // FIXME: This assumes that wchar_t is 32-bits for now.
> assert(PP.getTargetInfo().getWCharWidth() == 32 &&
> "Assumes sizeof(wchar_t) == 4 for now");
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list