]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: [E0534] inline attribute was malformed
authorMuhammad Mahad <mahadtxt@gmail.com>
Tue, 15 Aug 2023 13:52:10 +0000 (18:52 +0500)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:00:31 +0000 (19:00 +0100)
Inline attribute takes one argument, but
more than one argument was found.

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 case.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
gcc/rust/backend/rust-compile-base.cc
gcc/testsuite/rust/compile/inline_2.rs

index 5a0d9a16efde2901edb6d2c6020bf6c5c6a39595..186736875383051e860f524ab8f2b2f1b557240f 100644 (file)
@@ -247,7 +247,10 @@ HIRCompileBase::handle_inline_attribute_on_fndecl (tree fndecl,
   AST::AttrInputMetaItemContainer *meta_item = option.parse_to_meta_item ();
   if (meta_item->get_items ().size () != 1)
     {
-      rust_error_at (attr.get_locus (), "invalid number of arguments");
+      rich_location rich_locus (line_table, attr.get_locus ());
+      rich_locus.add_fixit_replace ("expected one argument");
+      rust_error_at (rich_locus, ErrorCode::E0534,
+                    "invalid number of arguments");
       return;
     }
 
index 3665fdac80452b87957624353003bae6a7d30552..1fa5862e10f0e4f705e75d8fe3ffceed0736dbd0 100644 (file)
@@ -4,3 +4,6 @@ fn test_a() {}
 
 #[inline(A, B)] // { dg-error "invalid number of arguments" }
 fn test_b() {}
+
+#[inline()] // { dg-error "invalid number of arguments" }
+fn test_c() {}
\ No newline at end of file