[cfe-commits] r69046 - /cfe/trunk/lib/Lex/LiteralSupport.cpp
Chris Lattner
clattner at apple.com
Wed Apr 15 07:44:34 PDT 2009
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
More information about the cfe-commits
mailing list