Skip to content

Commit

Permalink
gccrs: [E0534] inline attribute was malformed
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
MahadMuhammad authored and philberty committed Aug 16, 2023
1 parent 74b27ac commit 5545c75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gcc/rust/backend/rust-compile-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions gcc/testsuite/rust/compile/inline_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit 5545c75

Please sign in to comment.