Skip to content

Commit ac8c447

Browse files
committed
Treat u8 literals by their element type
1 parent f467a98 commit ac8c447

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎cpp2rust/converter/converter_lib.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ bool IsStringLiteralExpr(const clang::Expr *expr) {
259259

260260
bool IsCodeUnitStringLiteral(const clang::StringLiteral *expr) {
261261
return expr->getCharByteWidth() != 1 ||
262-
expr->getKind() == clang::StringLiteralKind::UTF8;
262+
expr->getType()->getArrayElementTypeNoTypeQual()->isChar8Type();
263263
}
264264

265265
bool IsUserDefinedDecl(const clang::Decl *decl) {

‎tests/unit/char_signed.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ int main() {
1919
printf("%d %d\n", lit[0], ulit[0]);
2020
printf("%d\n", is_negative(lit));
2121

22+
const char *u8s = u8"\u00e9";
23+
printf("%d %d\n", u8s[0], u8s[1]);
24+
2225
const char *p = "\x80";
2326
printf("%d %d\n", p[0], (unsigned char)p[0]);
2427

0 commit comments

Comments
 (0)