Skip to content

Conversation

@Pasta-coder
Copy link
Contributor

Emit a diagnostic when #[link_section] is used without arguments, matching rustc behavior. This prevents silent acceptance of empty attributes and provides a helpful diagnostic that shows the expected form.

Fixes #4229

gcc/rust/ChangeLog:

* util/rust-attributes.cc: Emit diagnostic for malformed link_section.

gcc/testsuite/ChangeLog:

* rust/compile/link_section-malformed.rs: New test.

@Pasta-coder Pasta-coder marked this pull request as draft January 6, 2026 13:26
@Pasta-coder Pasta-coder force-pushed the fix/link-section-malformed-4229 branch from 85fc427 to cf7149c Compare January 6, 2026 20:11
@Pasta-coder
Copy link
Contributor Author

drafted to resolve merge conflicts

@Pasta-coder Pasta-coder marked this pull request as ready for review January 7, 2026 17:57
@Pasta-coder
Copy link
Contributor Author

no merge conflicts , pr ready for review .

@P-E-P please review

thankyou .

@Pasta-coder Pasta-coder force-pushed the fix/link-section-malformed-4229 branch 3 times, most recently from a13b45c to ffb73a4 Compare January 7, 2026 20:03
@Pasta-coder Pasta-coder force-pushed the fix/link-section-malformed-4229 branch 2 times, most recently from 0be2b5b to 35a0548 Compare January 9, 2026 23:53
Emit a diagnostic when #[link_section] is used without arguments on
functions or static items, matching rustc behavior. This prevents
silent acceptance of empty attributes and provides a helpful
diagnostic that shows the expected form.

Fixes Rust-GCC#4229

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (check_link_section_attribute): New helper.
	(AttributeChecker::visit): Check link_section on functions and statics.

gcc/testsuite/ChangeLog:

	* rust/compile/link_section-malformed.rs: New test.

Signed-off-by: Jayant Chauhan <[email protected]>
@Pasta-coder Pasta-coder force-pushed the fix/link-section-malformed-4229 branch from 35a0548 to cc9081c Compare January 10, 2026 00:01
@Pasta-coder
Copy link
Contributor Author

I introduced a helper function , did requested changes .

thnakyou

@Pasta-coder Pasta-coder requested a review from P-E-P January 10, 2026 00:45
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.

malformed link_section attribute should give error

2 participants