Commit 212d55f
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/target_feature-unsafe.rs: New test.
* rust/compile/unsafe11.rs: Mark function as unsafe to satisfy new check.
Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>1 parent c35ffdb commit 212d55f
File tree
3 files changed
+26
-1
lines changed- gcc
- rust/util
- testsuite/rust/compile
3 files changed
+26
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
866 | 866 | | |
867 | 867 | | |
868 | 868 | | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
869 | 891 | | |
870 | 892 | | |
871 | 893 | | |
| |||
| 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 | | |
| |||
0 commit comments