]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: [E0535] Unknown argument given to inline attribute
authorMuhammad Mahad <mahadtxt@gmail.com>
Tue, 15 Aug 2023 14:07:52 +0000 (19:07 +0500)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:00:31 +0000 (19:00 +0100)
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>
gcc/rust/backend/rust-compile-base.cc
gcc/testsuite/rust/compile/inline_2.rs

index 186736875383051e860f524ab8f2b2f1b557240f..492588dfdf99f3739a5e18c1619b0ce575f461f9 100644 (file)
@@ -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%>");
     }
 }
 
index 1fa5862e10f0e4f705e75d8fe3ffceed0736dbd0..b6cfc83be72531f8c4b1d38784f34501177d82f4 100644 (file)
@@ -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" }