[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-07-14 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment. >> Additionally, the type of a character constant in C is int. > > This means that char32_t c4 = U'\U00064321'; is invalid in C No. A character constant that does not have an encoding prefix has type `int` in C. Character constants that have an encoding prefix have t

[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-07-13 Thread Sebastian Perta via Phabricator via cfe-commits
SebastianPerta added a comment. >> Additionally, the type of a character constant in C is int. This means that char32_t c4 = U'\U00064321'; is invalid in C. I know that is clang more strict with the standard than GCC, however I would like to mention that in GCC the value is not truncated to 16

[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-06-21 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added inline comments. Comment at: clang/lib/Lex/LiteralSupport.cpp:1600 - llvm::APInt LitVal(PP.getTargetInfo().getIntWidth(), 0); + llvm::APInt LitVal(PP.getTargetInfo().getChar32Width(), 0); sammccall wrote: > tahonermann wrote: > > I don't t

[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments. Comment at: clang/lib/Lex/LiteralSupport.cpp:1600 - llvm::APInt LitVal(PP.getTargetInfo().getIntWidth(), 0); + llvm::APInt LitVal(PP.getTargetInfo().getChar32Width(), 0); tahonermann wrote: > I don't think this is quite righ

[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-06-09 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann requested changes to this revision. tahonermann added a comment. This revision now requires changes to proceed. When submitting patches, please create the diff with context so that the code can be navigated in Phabricator. See https://llvm.org/docs/Phabricator.html#phabricator-reques

[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-06-09 Thread Sebastian Perta via Phabricator via cfe-commits
SebastianPerta added a comment. >> Regarding testing, it seems like this should change the diagnostic emitted >> for long x = 'abc' from "Character constant too long for its type" to >> "Multi-character character constant" when the target is AVR? Currently on RL78 it returns this warning withou

[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-06-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D127363#3570169 , @sammccall wrote: > In D127363#3570150 , @aaron.ballman > wrote: > >>> On 16 bit architectures char32_t literals are truncated, for example >>> U'\U00064321' w

[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-06-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment. In D127363#3570150 , @aaron.ballman wrote: >> On 16 bit architectures char32_t literals are truncated, for example >> U'\U00064321' will be truncated to 0x4321. > > Is that valid? > > https://eel.is/c++draft/basic.types#basic.

[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-06-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: tahonermann. aaron.ballman added a subscriber: tahonermann. aaron.ballman added a comment. > On 16 bit architectures char32_t literals are truncated, for example > U'\U00064321' will be truncated to 0x4321. Is that valid? https://eel.is/c++draft/basic.types#basic

[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-06-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment. This sounds correct to me, though I don't feel like an expert here. Upstream in non-experimental IntWidth == Char32Width except on AVR, so it won't actually break anything. Regarding testing, it seems like this should change the diagnostic emitted for `long x = 'abc'`

[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-06-08 Thread Sebastian Perta via Phabricator via cfe-commits
SebastianPerta created this revision. SebastianPerta added reviewers: aaron.ballman, sammccall, DaanDeMeyer. Herald added a subscriber: dylanmckay. Herald added a project: All. SebastianPerta requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.