[PATCH] D135366: [clang][Interp] Implement String- and CharacterLiterals

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 9 16:06:58 PDT 2022


shafik added inline comments.


================
Comment at: clang/test/AST/Interp/arrays.cpp:128
+
+  static_assert("foobar"[2] == 'o', "");
+
----------------
Also `2["foobar"]`


================
Comment at: clang/test/AST/Interp/arrays.cpp:135
+  static_assert(u32[1] == U'b', "");
+};
+
----------------
tbaeder wrote:
> aaron.ballman wrote:
> > I think you need a more coverage for character literals. Some test cases that are interesting: multichar literals (`'abcd'`), character literals with UCNs (`'\uFFFF'`), character literals with numeric escapes (`'\xFF'`). I'm especially interested in seeing whether we handle integer promotions properly, especially when promoting to `unsigned int`.
> I added two more test cases but I'm generally not that familiar with character  literal edge cases and integer promotion, so if you have concrete test cases in mind, that would be great :)
We can find GNU documentation of multi-char literals here: https://gcc.gnu.org/onlinedocs/cpp/Implementation-defined-behavior.html#Implementation-defined-behavior and I believe we follow the same scheme. 

There are some weird cases like `'\8'` which compilers seem to treat consistently but generate a diagnostic for.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135366/new/

https://reviews.llvm.org/D135366



More information about the cfe-commits mailing list