]> git.proxmox.com Git - rustc.git/blame - src/test/ui/target-feature/invalid-attribute.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / ui / target-feature / invalid-attribute.rs
CommitLineData
2c00a5a8
XL
1// ignore-arm
2// ignore-aarch64
3// ignore-wasm
4// ignore-emscripten
83c7162d 5// ignore-mips
b7449926 6// ignore-mips64
83c7162d 7// ignore-powerpc
94b46f34
XL
8// ignore-powerpc64
9// ignore-powerpc64le
f035d41b 10// ignore-riscv64
83c7162d 11// ignore-s390x
94b46f34
XL
12// ignore-sparc
13// ignore-sparc64
2c00a5a8
XL
14
15#![feature(target_feature)]
1b1a35ee 16#![warn(unused_attributes)]
2c00a5a8
XL
17
18#[target_feature = "+sse2"]
dc9dc135 19//~^ ERROR malformed `target_feature` attribute
2c00a5a8 20#[target_feature(enable = "foo")]
dc9dc135
XL
21//~^ ERROR not valid for this target
22//~| NOTE `foo` is not valid for this target
2c00a5a8 23#[target_feature(bar)]
dc9dc135 24//~^ ERROR malformed `target_feature` attribute
2c00a5a8 25#[target_feature(disable = "baz")]
dc9dc135 26//~^ ERROR malformed `target_feature` attribute
2c00a5a8
XL
27unsafe fn foo() {}
28
29#[target_feature(enable = "sse2")]
416331ca 30//~^ ERROR `#[target_feature(..)]` can only be applied to `unsafe` functions
f9f354fc 31//~| NOTE see issue #69098
2c00a5a8 32fn bar() {}
dc9dc135 33//~^ NOTE not an `unsafe` function
2c00a5a8 34
0531ce1d 35#[target_feature(enable = "sse2")]
dc9dc135 36//~^ ERROR attribute should be applied to a function
0531ce1d 37mod another {}
dc9dc135 38//~^ NOTE not a function
0531ce1d 39
e74abb32
XL
40#[target_feature(enable = "sse2")]
41//~^ ERROR attribute should be applied to a function
42const FOO: usize = 7;
43//~^ NOTE not a function
44
45#[target_feature(enable = "sse2")]
46//~^ ERROR attribute should be applied to a function
47struct Foo;
48//~^ NOTE not a function
49
50#[target_feature(enable = "sse2")]
51//~^ ERROR attribute should be applied to a function
1b1a35ee 52enum Bar {}
e74abb32
XL
53//~^ NOTE not a function
54
55#[target_feature(enable = "sse2")]
56//~^ ERROR attribute should be applied to a function
1b1a35ee 57union Qux {
e74abb32 58//~^ NOTE not a function
1b1a35ee
XL
59 f1: u16,
60 f2: u16,
61}
e74abb32
XL
62
63#[target_feature(enable = "sse2")]
64//~^ ERROR attribute should be applied to a function
1b1a35ee 65trait Baz {}
e74abb32
XL
66//~^ NOTE not a function
67
0531ce1d 68#[inline(always)]
416331ca 69//~^ ERROR: cannot use `#[inline(always)]`
0531ce1d
XL
70#[target_feature(enable = "sse2")]
71unsafe fn test() {}
72
f9f354fc
XL
73trait Quux {
74 fn foo();
75}
76
77impl Quux for Foo {
78 #[target_feature(enable = "sse2")]
79 //~^ ERROR `#[target_feature(..)]` can only be applied to `unsafe` functions
80 //~| NOTE see issue #69098
81 fn foo() {}
82 //~^ NOTE not an `unsafe` function
83}
84
2c00a5a8 85fn main() {
1b1a35ee
XL
86 #[target_feature(enable = "sse2")]
87 //~^ ERROR attribute should be applied to a function
2c00a5a8
XL
88 unsafe {
89 foo();
90 bar();
91 }
1b1a35ee
XL
92 //~^^^^ NOTE not a function
93
f9f354fc 94 #[target_feature(enable = "sse2")]
1b1a35ee 95 //~^ ERROR attribute should be applied to a function
f9f354fc 96 || {};
1b1a35ee 97 //~^ NOTE not a function
2c00a5a8 98}