gccrs: Add support for `#[repr(transparent)]` attribute
Enables parsing and basic type-checking for Rust's `#[repr(transparent)]` attribute.
This commit introduces the necessary infrastructure within gccrs to recognize and process the #[repr(transparent)] attribute. It adds a variant to the ReprKind enum and modifies the type-checking logic to parse this attribute, enforcing that transparent structs or enums must have exactly one field. This lays the groundwork for the subsequent implementation of its compilation.
In Details
The gccrs type-checking pipeline is extended to handle the #[repr(transparent)] attribute. A new TRANSPARENT variant is added to TyTy::ADTType::ReprKind, and TypeCheckBase::parse_repr_options is updated to parse this attribute. Additionally, TypeCheckItem::visit (StructStruct) now enforces the single-field constraint for transparent ADTs, ensuring correct type-system semantics before backend code generation.
- `#[repr(transparent)]` attribute
- A Rust attribute that indicates a struct or enum with a single field should have the same memory layout and ABI as that single field. This is commonly used for creating newtypes that are FFI-compatible with C types.
- type checking
- The process of verifying and enforcing the constraints of types in source code. It ensures that operations are performed on compatible data types, preventing type errors.
- ABI
- Application Binary Interface. Defines how low-level code (like compiled functions and data structures) interacts at the binary level, including calling conventions, data layout, and system calls. Important for interoperability between different languages or compiled components.
- ADT
- Algebraic Data Type. A type formed by combining other types using sums (enums) and products (structs). Rust's structs and enums are ADTs.