]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/non-interger-atomic.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / non-interger-atomic.rs
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
11 #![feature(core_intrinsics, rustc_attrs)]
12 #![allow(warnings)]
13
14 use std::intrinsics;
15
16 #[derive(Copy, Clone)]
17 struct Foo(i64);
18 type Bar = &'static Fn();
19 type Quux = [u8; 100];
20
21 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
22 unsafe fn test_bool_load(p: &mut bool, v: bool) {
23 intrinsics::atomic_load(p);
24 //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `bool`
25 }
26
27 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
28 unsafe fn test_bool_store(p: &mut bool, v: bool) {
29 intrinsics::atomic_store(p, v);
30 //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `bool`
31 }
32
33 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
34 unsafe fn test_bool_xchg(p: &mut bool, v: bool) {
35 intrinsics::atomic_xchg(p, v);
36 //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `bool`
37 }
38
39 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
40 unsafe fn test_bool_cxchg(p: &mut bool, v: bool) {
41 intrinsics::atomic_cxchg(p, v, v);
42 //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `bool`
43 }
44
45 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
46 unsafe fn test_Foo_load(p: &mut Foo, v: Foo) {
47 intrinsics::atomic_load(p);
48 //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `Foo`
49 }
50
51 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
52 unsafe fn test_Foo_store(p: &mut Foo, v: Foo) {
53 intrinsics::atomic_store(p, v);
54 //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `Foo`
55 }
56
57 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
58 unsafe fn test_Foo_xchg(p: &mut Foo, v: Foo) {
59 intrinsics::atomic_xchg(p, v);
60 //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `Foo`
61 }
62
63 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
64 unsafe fn test_Foo_cxchg(p: &mut Foo, v: Foo) {
65 intrinsics::atomic_cxchg(p, v, v);
66 //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `Foo`
67 }
68
69 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
70 unsafe fn test_Bar_load(p: &mut Bar, v: Bar) {
71 intrinsics::atomic_load(p);
72 //~^ ERROR expected basic integer type, found `&'static std::ops::Fn() + 'static`
73 }
74
75 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
76 unsafe fn test_Bar_store(p: &mut Bar, v: Bar) {
77 intrinsics::atomic_store(p, v);
78 //~^ ERROR expected basic integer type, found `&'static std::ops::Fn() + 'static`
79 }
80
81 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
82 unsafe fn test_Bar_xchg(p: &mut Bar, v: Bar) {
83 intrinsics::atomic_xchg(p, v);
84 //~^ ERROR expected basic integer type, found `&'static std::ops::Fn() + 'static`
85 }
86
87 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
88 unsafe fn test_Bar_cxchg(p: &mut Bar, v: Bar) {
89 intrinsics::atomic_cxchg(p, v, v);
90 //~^ ERROR expected basic integer type, found `&'static std::ops::Fn() + 'static`
91 }
92
93 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
94 unsafe fn test_Quux_load(p: &mut Quux, v: Quux) {
95 intrinsics::atomic_load(p);
96 //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]`
97 }
98
99 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
100 unsafe fn test_Quux_store(p: &mut Quux, v: Quux) {
101 intrinsics::atomic_store(p, v);
102 //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]`
103 }
104
105 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
106 unsafe fn test_Quux_xchg(p: &mut Quux, v: Quux) {
107 intrinsics::atomic_xchg(p, v);
108 //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]`
109 }
110
111 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
112 unsafe fn test_Quux_cxchg(p: &mut Quux, v: Quux) {
113 intrinsics::atomic_cxchg(p, v, v);
114 //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]`
115 }
116
117 fn main() {}