rust/tests/ui/repr
Jubilee Young 2edf6c8784 Default repr(C) enums to c_int size
This is what ISO C strongly implies this is correct, and
many processor-specific ABIs imply or mandate this size, so
"everyone" (LLVM, gcc...) defaults to emitting enums this way.
However, this is by no means guaranteed by ISO C,
and the bare-metal Arm targets show it can be overridden,
which rustc supports via `c-enum-min-bits` in a target.json.

The override is a flag named `-fshort-enums` in clang and gcc,
but introducing a CLI flag is probably unnecessary for rustc.
This flag can be used by non-Arm microcontroller targets,
like AVR and MSP430, but it is not enabled for them by default.
Rust programmers who know the size of a target's enums
can use explicit reprs, which also lets them match C23 code.

This change is most relevant to 16-bit targets: AVR and MSP430.
Most of rustc's targets use 32-bit ints, but ILP64 does exist.
Regardless, rustc should now correctly handle enums for
both very small and very large targets.

Thanks to William for confirming MSP430 behavior,
and to Waffle for better style and no-core size_of asserts.

Co-authored-by: William D. Jones <thor0505@comcast.net>
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
2023-02-16 15:06:17 -08:00
..
auxiliary Move /src/test to /tests 2023-01-11 09:32:08 +00:00
16-bit-repr-c-enum.rs Default repr(C) enums to c_int size 2023-02-16 15:06:17 -08:00
align-with-extern-c-fn.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
aligned_enum_cast.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
attr-usage-repr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
attr-usage-repr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid_repr_list_help.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid_repr_list_help.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-83505-repr-simd.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-83505-repr-simd.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-83921-ice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-83921-ice.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr_c_int_align.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-align-assign.fixed Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-align-assign.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-align-assign.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-align.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-align.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-disallow-on-variant.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-disallow-on-variant.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-packed-contains-align.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-packed-contains-align.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-issue-87496.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-issue-87496.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-non-exhaustive.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-non-exhaustive.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-other-items.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-other-items.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-other-reprs.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent-other-reprs.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr-transparent.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transparent-enum-too-many-variants.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transparent-enum-too-many-variants.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00