aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuhammad Mahad <mahadtxt@gmail.com>2023-08-15 19:07:52 +0500
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 19:00:31 +0100
commit87ccd32da00e82584215c759e80bd092003c9efb (patch)
tree90f44d101b3b2e93b308e4ecb34c5034cd7d4611
parent0ae1af0eb31d99f4cd5ba05a199770aeee764567 (diff)
downloadgcc-87ccd32da00e82584215c759e80bd092003c9efb.zip
gcc-87ccd32da00e82584215c759e80bd092003c9efb.tar.gz
gcc-87ccd32da00e82584215c759e80bd092003c9efb.tar.bz2
gccrs: [E0535] Unknown argument given to inline attribute
The inline attribute only supports two arguments: - always - never All other arguments given to the inline attribute will return error. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::handle_inline_attribute_on_fndecl): Added rich_location & error code. gcc/testsuite/ChangeLog: * rust/compile/inline_2.rs: Added new message. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
-rw-r--r--gcc/rust/backend/rust-compile-base.cc6
-rw-r--r--gcc/testsuite/rust/compile/inline_2.rs2
2 files changed, 6 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc
index 1867368..492588d 100644
--- a/gcc/rust/backend/rust-compile-base.cc
+++ b/gcc/rust/backend/rust-compile-base.cc
@@ -275,7 +275,11 @@ HIRCompileBase::handle_inline_attribute_on_fndecl (tree fndecl,
}
else
{
- rust_error_at (attr.get_locus (), "unknown inline option");
+ rich_location rich_locus (line_table, attr.get_locus ());
+ rich_locus.add_fixit_replace ("unknown inline option");
+ rust_error_at (rich_locus, ErrorCode::E0535,
+ "invalid argument, %<inline%> attribute only accepts "
+ "%<always%> or %<never%>");
}
}
diff --git a/gcc/testsuite/rust/compile/inline_2.rs b/gcc/testsuite/rust/compile/inline_2.rs
index 1fa5862..b6cfc83 100644
--- a/gcc/testsuite/rust/compile/inline_2.rs
+++ b/gcc/testsuite/rust/compile/inline_2.rs
@@ -1,5 +1,5 @@
// { dg-additional-options "-w" }
-#[inline(A)] // { dg-error "unknown inline option" }
+#[inline(A)] // { dg-error "invalid argument, .inline. attribute only accepts .always. or .never." }
fn test_a() {}
#[inline(A, B)] // { dg-error "invalid number of arguments" }