Skip to content

Conversation

P-E-P
Copy link
Member

@P-E-P P-E-P commented Oct 1, 2025

Fixes #4164

P-E-P added 4 commits October 1, 2025 12:36
Path must be made of a single literal item, otherwise an error should be
thrown.

gcc/rust/ChangeLog:

	* util/rust-attributes.cc (AttributeChecker::check_attribute): Recurse
	within attr input for additional attribute checking.
	(AttributeChecker::visit): Remove empty definition in favor of default
	ast visitor definition.
	* util/rust-attributes.h: Remove now unused prototypes.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
gcc/rust/ChangeLog:

	* ast/rust-ast.h: Add missing override modifier.
	* ast/rust-path.h: Likewise.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
We still don't know which location should be preferred over the other,
this means that nobody should rely on this function's return value.

gcc/rust/ChangeLog:

	* ast/rust-expr.h: Force crash when retrieving locus.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
Add location for malformed attribute errors and avoid processing of
malformed attributes.

gcc/rust/ChangeLog:

	* ast/rust-ast.cc (AttrInputMetaItemContainer::separate_cfg_attrs):
	Avoid malformed attributes.
	* util/rust-attributes.cc (AttributeChecker::visit): Change location.

gcc/testsuite/ChangeLog:

	* rust/compile/attr_malformed_path.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
@P-E-P P-E-P requested a review from CohenArthur October 1, 2025 14:40
@P-E-P P-E-P changed the title Attribute segfault Fix malformed path segfault in attributes Oct 1, 2025
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM good catch! Thanks!

@CohenArthur CohenArthur added this pull request to the merge queue Oct 2, 2025
Merged via the queue into Rust-GCC:master with commit 6ec1929 Oct 2, 2025
13 checks passed
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.

ICE in to_attribute, at rust/ast/rust-ast.cc:4132 cfg_attr

2 participants