Repr attributes on ADTs do not have restrictions.
According to rust, the valid repr attributes are Rust (default), C, align, packed, transparent, simd, i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize and usize.
But gccrs allows us to use anything as the attribute and this code compiles without any error.
#[repr(this_repr_doesnot_exist)]
enum Starter{
Bulbasaur,
Charmander,
Squirtle,
}
#[repr(!)]
enum Type{
Grass,
Fire,
Water,
}
#[repr(hmmmmmmm)]
struct Stats {
base_attack: u32,
base_defense: u32,
base_speed: u32,
}
fn main(){}
Godbolt: https://godbolt.org/z/f8rhET9ch
yeah we should probably do that in the attributes checker I think? would probably make sense, as for example repr(...) cannot use type aliases or anything like that: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=eb6470d9855df67c57f53619392970b8
Yeah attributes checker makes sense then i think either directly in the backend where we have some repr support for packed and aligned for now. If this only works on builtin types then i think it should be handy enough to change the discriminant field type.
I am currently working on enums a fair bit these days I think our layout might be wrong after reviewing gdb code for a while again.