Issue 142633
Summary [BUG] Missing TypeKind for _Float16 (CXType_Float16 = 32) in Python bindings
Labels new issue
Assignees
Reporter zokrezyl
    ## [BUG] Missing TypeKind for _Float16 (CXType_Float16 = 32) in Python bindings

### Summary

When using Clang Python bindings (`clang.cindex`) with `libclang` 19.1.7, accessing `.type.kind` for a variable of type `_Float16` crashes with:

```
ValueError: 32 is not a valid TypeKind
```

This is because `CXType_Float16 = 32` is defined in `clang/include/clang-c/Index.h` but missing in the Python `TypeKind` enum in `cindex.py`.

### Repro

```c
// test.c
_Float16 f;
```

```python
from clang import cindex
tu = cindex.Index.create().parse("test.c", args=["-x", "c"])
for c in tu.cursor.walk_preorder():
    print(c.type.spelling)       # "_Float16"
    print(c.type.kind)           # 💥 raises ValueError: 32 is not a valid TypeKind
```

### Expected

No crash; `.type.kind` should return a valid enum like `TypeKind.FLOAT16`.

### Fix

Add to `clang/cindex.py`:
```python
FLOAT16 = 32
```

### Environment

- libclang: 19.1.7
- Python: 3.13
- OS: macOS
- Python bindings: from LLVM Homebrew package or PyPI

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to