[clang] [clang-repl] Ensure clang-repl accepts all C keywords supported in all language models (PR #142749)
Anutosh Bhat via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 4 02:19:43 PDT 2025
anutosh491 wrote:
On **Main**
```
anutosh491 at vv-nuc:/build/anutosh491/llvm-project/build/bin$ ./clang-repl
clang-repl> _Alignas(16) int x;
clang-repl> int align = _Alignof(double);
clang-repl> _Atomic int atomic_var = 0;
clang-repl> _Complex double complex_val = 1.0 + 2.0i;
clang-repl> _Float16 f = 1.5;
clang-repl> _Thread_local int counter = 0;
clang-repl> _Static_assert(sizeof(int) == 4, "int must be 4 bytes");
clang-repl> _Imaginary float i = 2.0f;
In file included from <<< inputs >>>:1:
input_line_8:1:1: error: expected expression
1 | _Imaginary float i = 2.0f;
| ^
error: Parsing failed.
clang-repl> _Noreturn void die() { while (true) {}}
input_line_9:1:1: error: expected expression
1 | _Noreturn void die() { while (true) {}}
| ^
error: Parsing failed.
```
On **Branch** after the change
```
anutosh491 at vv-nuc:/build/anutosh491/llvm-project/build/bin$ ./clang-repl
clang-repl> _Alignas(16) int x;
clang-repl> int align = _Alignof(double);
clang-repl> _Atomic int atomic_var = 0;
clang-repl> _Complex double complex_val = 1.0 + 2.0i;
clang-repl> _Float16 f = 1.5;
clang-repl> _Thread_local int counter = 0;
clang-repl> _Static_assert(sizeof(int) == 4, "int must be 4 bytes");
clang-repl> _Imaginary float i = 2.0f;
In file included from <<< inputs >>>:1:
input_line_8:1:1: error: imaginary types are not supported
1 | _Imaginary float i = 2.0f;
| ^
error: Parsing failed.
clang-repl> _Noreturn void die() { while (true) {}}
```
This now works how clang would expect it to. For eg
```
(xeus-cpp) anutosh491 at Anutoshs-MacBook-Air xeus-cpp % cat test-file.cpp
_Imaginary float i = 2.0f;%
(xeus-cpp) anutosh491 at Anutoshs-MacBook-Air xeus-cpp % clang++ -std=c++20 test-file.cpp -o test_program
test-file.cpp:1:1: error: imaginary types are not supported
_Imaginary float i = 2.0f;
^
1 error generated.
```
And anything with _Noreturn would just compile fine.
https://github.com/llvm/llvm-project/pull/142749
More information about the cfe-commits
mailing list