r213657 - Provide extra information in the "integer constant is too large" diagnostic. This will be used to improve other diagnostics.

Aaron Ballman aaron at aaronballman.com
Tue Jul 22 18:04:51 PDT 2014


Latest incarnation.

~Aaron

On Tue, Jul 22, 2014 at 8:50 PM, Aaron Ballman <aaron at aaronballman.com> wrote:
> On Tue, Jul 22, 2014 at 8:45 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>> On Tue, Jul 22, 2014 at 5:38 PM, Aaron Ballman <aaron at aaronballman.com>
>> wrote:
>>>
>>> How do these sound to you?
>>>
>>> On Tue, Jul 22, 2014 at 8:13 PM, Richard Smith <richard at metafoo.co.uk>
>>> wrote:
>>> > +def err_integer_literal_too_large : Error<
>>> > +  "integer literal is a value that cannot be represented as
>>> > %select{a|an}0
>>> > "
>>> > +  "%select{signed|unsigned}0 integer">;
>>> >
>>> > I don't think the "is a value that" adds anything here. Also, I'd like
>>> > to
>>> > see something that more directly says we don't have a signed/unsigned
>>> > integer type large enough.
>>>
>>> "integer literal is too large to be represented in %select{a|an}0
>>> %select{signed|unsigned}0 integer type"
>>
>>
>> Perhaps "... to be represented in any %select{signed |}0integer type"?
>
> Works for me.
>
>>
>>>
>>> >  def err_integer_too_large : Error<
>>> > -  "integer constant is larger than the largest %0-bit unsigned integer
>>> > type">;
>>> > -def ext_integer_too_large_for_signed : ExtWarn<
>>> > -  "integer constant is larger than the largest %0-bit signed integer
>>> > type">,
>>> > +  "integer constant evaluates to value %0 that cannot be represented as
>>> > a "
>>> > +  "%1-bit %select{signed|unsigned}2 integer">;
>>> >
>>> > Please rename this to something about ICEs, and move it to
>>> > DiagnosticSemaKinds next to the existing err_ice_ diagnostics. (This is
>>> > pretty similar to ext_cce_narrowing...)
>>> >
>>> >
>>> > +def ext_integer_literal_too_large_for_signed : ExtWarn<
>>> > +  "integer literal is a value that cannot be represented as a signed
>>> > integer, "
>>> > +  "and will instead be interpreted as unsigned">,
>>> >
>>> > Again, mentioning integer types and not just integers would make this
>>> > clearer.
>>>
>>> "integer literal is too large to be represented in a signed integer
>>> type, and will instead be interpreted as unsigned integer type"
>>
>>
>> Can we specify the type here? I think it's always 'unsigned long long' when
>> we reach this diagnostic.
>
> It's not always unsigned long long -- this gets used in EvaluateValue
> in PPExpressions.cpp, and we only set the resulting value to unsigned,
> but not change its type.
>
> ~Aaron
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NumericLiteral.patch
Type: application/octet-stream
Size: 9064 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140722/1d964bf8/attachment.obj>


More information about the cfe-commits mailing list