/src/test/ui/feature-gate-cfg-target-has-atomic.rs

https://gitlab.com/jianglu/rust · Rust · 86 lines · 57 code · 5 blank · 24 comment · 0 complexity · a5262e2ad61262cd39bb344708101131 MD5 · raw file

  1. // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
  2. // file at the top-level directory of this distribution and at
  3. // http://rust-lang.org/COPYRIGHT.
  4. //
  5. // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
  6. // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
  7. // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
  8. // option. This file may not be copied, modified, or distributed
  9. // except according to those terms.
  10. #![crate_type="rlib"]
  11. #![no_core]
  12. extern "rust-intrinsic" {
  13. fn atomic_xadd<T>(dst: *mut T, src: T) -> T;
  14. }
  15. #[lang = "sized"]
  16. trait Sized {}
  17. #[lang = "copy"]
  18. trait Copy {}
  19. #[cfg(target_has_atomic = "8")]
  20. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  21. pub unsafe fn atomic_u8(x: *mut u8) {
  22. atomic_xadd(x, 1);
  23. atomic_xadd(x, 1);
  24. }
  25. #[cfg(target_has_atomic = "8")]
  26. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  27. pub unsafe fn atomic_i8(x: *mut i8) {
  28. atomic_xadd(x, 1);
  29. }
  30. #[cfg(target_has_atomic = "16")]
  31. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  32. pub unsafe fn atomic_u16(x: *mut u16) {
  33. atomic_xadd(x, 1);
  34. }
  35. #[cfg(target_has_atomic = "16")]
  36. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  37. pub unsafe fn atomic_i16(x: *mut i16) {
  38. atomic_xadd(x, 1);
  39. }
  40. #[cfg(target_has_atomic = "32")]
  41. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  42. pub unsafe fn atomic_u32(x: *mut u32) {
  43. atomic_xadd(x, 1);
  44. }
  45. #[cfg(target_has_atomic = "32")]
  46. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  47. pub unsafe fn atomic_i32(x: *mut i32) {
  48. atomic_xadd(x, 1);
  49. }
  50. #[cfg(target_has_atomic = "64")]
  51. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  52. pub unsafe fn atomic_u64(x: *mut u64) {
  53. atomic_xadd(x, 1);
  54. }
  55. #[cfg(target_has_atomic = "64")]
  56. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  57. pub unsafe fn atomic_i64(x: *mut i64) {
  58. atomic_xadd(x, 1);
  59. }
  60. #[cfg(target_has_atomic = "ptr")]
  61. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  62. pub unsafe fn atomic_usize(x: *mut usize) {
  63. atomic_xadd(x, 1);
  64. }
  65. #[cfg(target_has_atomic = "ptr")]
  66. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  67. pub unsafe fn atomic_isize(x: *mut isize) {
  68. atomic_xadd(x, 1);
  69. }
  70. fn main() {
  71. cfg!(target_has_atomic = "8");
  72. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  73. cfg!(target_has_atomic = "16");
  74. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  75. cfg!(target_has_atomic = "32");
  76. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  77. cfg!(target_has_atomic = "64");
  78. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  79. cfg!(target_has_atomic = "ptr");
  80. //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976)
  81. }