Why is CharacterLiteral::getValue() unsigned?

Am I misreading the C99 standard, 6.4.4.4#10, where it
says "An integer character constant has type int"?
Thanks,

    Roberto

The type of the literal and the type of getValue() are not necessarily tied. This just means that the value zero extends when you ask for it. If you cast it back to char, you can get whatever you want.

To answer your specific question, the reason for this is that clang supports the "multibyte char" extension, which looks like 'abcd'. Yes this is a horrible thing. :slight_smile:

-Chris

Chris Lattner wrote:

Am I misreading the C99 standard, 6.4.4.4#10, where it
says "An integer character constant has type int"?
Thanks,

The type of the literal and the type of getValue() are not necessarily tied. This just means that the value zero extends when you ask for it. If you cast it back to char, you can get whatever you want.

To answer your specific question, the reason for this is that clang supports the "multibyte char" extension, which looks like 'abcd'. Yes this is a horrible thing. :slight_smile:

To the contrary: I need to support that extension!