Commit 4ce4e1e
committed
util/attributes: Check that #[target_feature] is only used on unsafe functions
The #[target_feature] attribute allows code generation that may not be
supported by the runtime hardware, making it inherently unsafe. This
patch adds a check to ensure it is only applied to functions declared
as 'unsafe', matching rustc behavior (E0658).
Fixes #4234
gcc/rust/ChangeLog:
* util/rust-attributes.cc (AttributeChecker::visit): Error if target_feature is on safe function.
gcc/testsuite/ChangeLog:
* rust/compile/issue-4234.rs: New test.
* rust/compile/unsafe11.rs: Mark function as unsafe to match new restriction.
Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>1 parent 17231c8 commit 4ce4e1e
File tree
3 files changed
+16
-2
lines changed- gcc
- rust/util
- testsuite/rust/compile
3 files changed
+16
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
898 | 898 | | |
899 | 899 | | |
900 | 900 | | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
901 | 911 | | |
902 | 912 | | |
903 | 913 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
8 | 9 | | |
0 commit comments