Skip to content

Conversation

@Pasta-coder
Copy link
Contributor

Emit a diagnostic when #[export_name] is used without arguments or with invalid arguments (non-string literals). This prevents silent failures or backend crashes when lowering the attribute to GIMPLE, ensuring the attribute follows the expected form: #[export_name = name].

Fixes #4387

gcc/rust/ChangeLog:

* util/rust-attributes.cc (check_export_name_attribute): New helper.
(AttributeChecker::visit): Check export_name on functions.

gcc/testsuite/ChangeLog:

* rust/compile/issue-4387.rs: New test.

Emit a diagnostic when #[export_name] is used without arguments or
with invalid arguments (non-string literals). This prevents silent
failures or backend crashes when lowering the attribute to GIMPLE,
ensuring the attribute follows the expected form: #[export_name = name].

Fixes Rust-GCC#4387

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (check_export_name_attribute): New helper.
	(AttributeChecker::visit): Check export_name on functions.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4387.rs: New test.

Signed-off-by: Jayant Chauhan <[email protected]>
@P-E-P P-E-P enabled auto-merge January 15, 2026 17:45
@P-E-P P-E-P added this pull request to the merge queue Jan 15, 2026
Merged via the queue into Rust-GCC:master with commit 5b9706f Jan 15, 2026
12 checks passed
@Pasta-coder Pasta-coder deleted the issue-4387 branch January 16, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check export_name attribute correctness

2 participants