Skip to content

Commit

Permalink
gccrs: [E0535] Unknown argument given to inline attribute
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
MahadMuhammad authored and CohenArthur committed Jan 16, 2024
1 parent 8baf00e commit fb3f64a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion gcc/rust/backend/rust-compile-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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%>");
}
}

Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/rust/compile/inline_2.rs
Original file line number Diff line number Diff line change
@@ -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" }
Expand Down

0 comments on commit fb3f64a

Please sign in to comment.