Commit 4d60acd
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):
Reject #[target_feature] on non-unsafe functions.
gcc/testsuite/ChangeLog:
* rust/compile/issue-4234.rs: New test.
* rust/compile/unsafe11.rs: Mark function as unsafe to
to satisfy new #[target_feature] restriction.
Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>1 parent 9288848 commit 4d60acd
File tree
3 files changed
+13
-2
lines changed- gcc
- rust/util
- testsuite/rust/compile
3 files changed
+13
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
885 | 885 | | |
886 | 886 | | |
887 | 887 | | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
888 | 895 | | |
889 | 896 | | |
890 | 897 | | |
| |||
| 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