[cfe-commits] r69046 - /cfe/trunk/lib/Lex/LiteralSupport.cpp
Sanjiv Gupta
sanjiv.gupta at microchip.com
Sat Apr 18 23:32:11 PDT 2009
Chris Lattner wrote:
>
> On Apr 15, 2009, at 7:21 AM, Sanjiv Gupta wrote:
>
>> Chris Lattner wrote:
>>>
>>> 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
>> Chris,
>> I can take it up. Do you have any ideas how this should be handled?
>
> Two options: you can use APInt with a bitwidth set to the width of
> 'int', or you could do overflow detection within the unsigned. Using
> an APInt is probably the best way to go.
>
> Thanks Sanjiv,
>
> -Chris
>
Chris,
Please find the patch attached. Let me know if it's ok to commit.
- Sanjiv
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Literal.patch
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20090419/0639d2be/attachment.ksh>
More information about the cfe-commits
mailing list