/src/test/ui/intrinsics/non-integer-atomic.rs

https://gitlab.com/rust-lang/rust · Rust · 92 lines · 56 code · 19 blank · 17 comment · 0 complexity · 6fbe9ebac7701ec58a72d18728566db1 MD5 · raw file

  1. // build-fail
  2. #![feature(core_intrinsics)]
  3. #![allow(warnings)]
  4. #![crate_type = "rlib"]
  5. use std::intrinsics;
  6. #[derive(Copy, Clone)]
  7. pub struct Foo(i64);
  8. pub type Bar = &'static Fn();
  9. pub type Quux = [u8; 100];
  10. pub unsafe fn test_bool_load(p: &mut bool, v: bool) {
  11. intrinsics::atomic_load(p);
  12. //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `bool`
  13. }
  14. pub unsafe fn test_bool_store(p: &mut bool, v: bool) {
  15. intrinsics::atomic_store(p, v);
  16. //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `bool`
  17. }
  18. pub unsafe fn test_bool_xchg(p: &mut bool, v: bool) {
  19. intrinsics::atomic_xchg(p, v);
  20. //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `bool`
  21. }
  22. pub unsafe fn test_bool_cxchg(p: &mut bool, v: bool) {
  23. intrinsics::atomic_cxchg(p, v, v);
  24. //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `bool`
  25. }
  26. pub unsafe fn test_Foo_load(p: &mut Foo, v: Foo) {
  27. intrinsics::atomic_load(p);
  28. //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `Foo`
  29. }
  30. pub unsafe fn test_Foo_store(p: &mut Foo, v: Foo) {
  31. intrinsics::atomic_store(p, v);
  32. //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `Foo`
  33. }
  34. pub unsafe fn test_Foo_xchg(p: &mut Foo, v: Foo) {
  35. intrinsics::atomic_xchg(p, v);
  36. //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `Foo`
  37. }
  38. pub unsafe fn test_Foo_cxchg(p: &mut Foo, v: Foo) {
  39. intrinsics::atomic_cxchg(p, v, v);
  40. //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `Foo`
  41. }
  42. pub unsafe fn test_Bar_load(p: &mut Bar, v: Bar) {
  43. intrinsics::atomic_load(p);
  44. //~^ ERROR expected basic integer type, found `&dyn Fn()`
  45. }
  46. pub unsafe fn test_Bar_store(p: &mut Bar, v: Bar) {
  47. intrinsics::atomic_store(p, v);
  48. //~^ ERROR expected basic integer type, found `&dyn Fn()`
  49. }
  50. pub unsafe fn test_Bar_xchg(p: &mut Bar, v: Bar) {
  51. intrinsics::atomic_xchg(p, v);
  52. //~^ ERROR expected basic integer type, found `&dyn Fn()`
  53. }
  54. pub unsafe fn test_Bar_cxchg(p: &mut Bar, v: Bar) {
  55. intrinsics::atomic_cxchg(p, v, v);
  56. //~^ ERROR expected basic integer type, found `&dyn Fn()`
  57. }
  58. pub unsafe fn test_Quux_load(p: &mut Quux, v: Quux) {
  59. intrinsics::atomic_load(p);
  60. //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]`
  61. }
  62. pub unsafe fn test_Quux_store(p: &mut Quux, v: Quux) {
  63. intrinsics::atomic_store(p, v);
  64. //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]`
  65. }
  66. pub unsafe fn test_Quux_xchg(p: &mut Quux, v: Quux) {
  67. intrinsics::atomic_xchg(p, v);
  68. //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]`
  69. }
  70. pub unsafe fn test_Quux_cxchg(p: &mut Quux, v: Quux) {
  71. intrinsics::atomic_cxchg(p, v, v);
  72. //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]`
  73. }