Skip to content

Commit aa962d6

Browse files
[clang-repl] Fix Value for platforms where unqualified char is unsigned (#86118)
Signedness of unqualified `char` is unspecified and varies between platforms. This patch adds `Char_U` in `REPL_BUILTIN_TYPES` to account for platforms that default to `unsigned char`.
1 parent fa3d789 commit aa962d6

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

clang/include/clang/Interpreter/Value.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class QualType;
7676
X(bool, Bool) \
7777
X(char, Char_S) \
7878
X(signed char, SChar) \
79+
X(unsigned char, Char_U) \
7980
X(unsigned char, UChar) \
8081
X(short, Short) \
8182
X(unsigned short, UShort) \

clang/unittests/Interpreter/InterpreterTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,12 @@ TEST(InterpreterTest, Value) {
340340
EXPECT_EQ(V1.getKind(), Value::K_Int);
341341
EXPECT_FALSE(V1.isManuallyAlloc());
342342

343+
Value V1b;
344+
llvm::cantFail(Interp->ParseAndExecute("char c = 42;"));
345+
llvm::cantFail(Interp->ParseAndExecute("c", &V1b));
346+
EXPECT_TRUE(V1b.getKind() == Value::K_Char_S ||
347+
V1b.getKind() == Value::K_Char_U);
348+
343349
Value V2;
344350
llvm::cantFail(Interp->ParseAndExecute("double y = 3.14;"));
345351
llvm::cantFail(Interp->ParseAndExecute("y", &V2));

0 commit comments

Comments
 (0)