/src/test/codegen/repr-transparent-aggregates-1.rs

https://gitlab.com/rust-lang/rust · Rust · 86 lines · 46 code · 21 blank · 19 comment · 0 complexity · bf7e4ce98682cf454657cfb4a7883e9f MD5 · raw file

  1. // compile-flags: -O -C no-prepopulate-passes
  2. //
  3. // ignore-arm
  4. // ignore-aarch64
  5. // ignore-mips
  6. // ignore-mips64
  7. // ignore-powerpc
  8. // ignore-powerpc64
  9. // ignore-riscv64 see codegen/riscv-abi
  10. // ignore-windows
  11. // See repr-transparent.rs
  12. #![feature(transparent_unions)]
  13. #![crate_type="lib"]
  14. #[derive(Clone, Copy)]
  15. #[repr(C)]
  16. pub struct BigS([u32; 16]);
  17. #[repr(transparent)]
  18. pub struct TsBigS(BigS);
  19. #[repr(transparent)]
  20. pub union TuBigS {
  21. field: BigS,
  22. }
  23. #[repr(transparent)]
  24. pub enum TeBigS {
  25. Variant(BigS),
  26. }
  27. // CHECK: define{{.*}}void @test_BigS({{%BigS\*|ptr}} [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], {{%BigS\*|ptr}} [[BIGS_ARG_ATTRS1:.*]] byval(%BigS) [[BIGS_ARG_ATTRS2:.*]])
  28. #[no_mangle]
  29. pub extern "C" fn test_BigS(_: BigS) -> BigS { loop {} }
  30. // CHECK: define{{.*}}void @test_TsBigS({{%TsBigS\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], {{%TsBigS\*|ptr}} [[BIGS_ARG_ATTRS1]] byval(%TsBigS) [[BIGS_ARG_ATTRS2:.*]])
  31. #[no_mangle]
  32. pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
  33. // CHECK: define{{.*}}void @test_TuBigS({{%TuBigS\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], {{%TuBigS\*|ptr}} [[BIGS_ARG_ATTRS1]] byval(%TuBigS) [[BIGS_ARG_ATTRS2:.*]])
  34. #[no_mangle]
  35. pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
  36. // CHECK: define{{.*}}void @test_TeBigS({{%"TeBigS::Variant"\*|ptr}} [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], {{%"TeBigS::Variant"\*|ptr}} [[BIGS_ARG_ATTRS1]] byval(%"TeBigS::Variant") [[BIGS_ARG_ATTRS2]])
  37. #[no_mangle]
  38. pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
  39. #[derive(Clone, Copy)]
  40. #[repr(C)]
  41. pub union BigU {
  42. foo: [u32; 16],
  43. }
  44. #[repr(transparent)]
  45. pub struct TsBigU(BigU);
  46. #[repr(transparent)]
  47. pub union TuBigU {
  48. field: BigU,
  49. }
  50. #[repr(transparent)]
  51. pub enum TeBigU {
  52. Variant(BigU),
  53. }
  54. // CHECK: define{{.*}}void @test_BigU({{%BigU\*|ptr}} [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], {{%BigU\*|ptr}} [[BIGU_ARG_ATTRS1:.*]] byval(%BigU) [[BIGU_ARG_ATTRS2:.*]])
  55. #[no_mangle]
  56. pub extern "C" fn test_BigU(_: BigU) -> BigU { loop {} }
  57. // CHECK: define{{.*}}void @test_TsBigU({{%TsBigU\*|ptr}} [[BIGU_RET_ATTRS1:.*]] sret(%TsBigU) [[BIGU_RET_ATTRS2:.*]], {{%TsBigU\*|ptr}} [[BIGU_ARG_ATTRS1]] byval(%TsBigU) [[BIGU_ARG_ATTRS2]])
  58. #[no_mangle]
  59. pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
  60. // CHECK: define{{.*}}void @test_TuBigU({{%TuBigU\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2:.*]], {{%TuBigU\*|ptr}} [[BIGU_ARG_ATTRS1]] byval(%TuBigU) [[BIGU_ARG_ATTRS2]])
  61. #[no_mangle]
  62. pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
  63. // CHECK: define{{.*}}void @test_TeBigU({{%"TeBigU::Variant"\*|ptr}} [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2:.*]], {{%"TeBigU::Variant"\*|ptr}} [[BIGU_ARG_ATTRS1]] byval(%"TeBigU::Variant") [[BIGU_ARG_ATTRS2]])
  64. #[no_mangle]
  65. pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }