Skip to content

lint: Fix ICE on error_mark_node in unused variable linter#4438

Open
Pasta-coder wants to merge 1 commit intoRust-GCC:masterfrom
Pasta-coder:issue-3910
Open

lint: Fix ICE on error_mark_node in unused variable linter#4438
Pasta-coder wants to merge 1 commit intoRust-GCC:masterfrom
Pasta-coder:issue-3910

Conversation

@Pasta-coder
Copy link
Contributor

Fixes #3910

When encountering experimental or unsupported features like const generics,
the compiler can insert an `error_mark_node` into the declaration lists.
The unused variable linter was attempting to assert the `TREE_CODE` of
these nodes, resulting in an Internal Compiler Error (ICE).

This patch adds an early return for `error_mark_node` in `check_decl`
to prevent the ICE and allow the compiler to exit gracefully, correctly
emitting the standard compilation errors instead.

Fixes Rust-GCC#3910

gcc/rust/ChangeLog:

	* checks/lints/rust-lint-unused-var.cc (check_decl): Return early
	if the tree is an error_mark_node.

gcc/testsuite/ChangeLog:

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

Signed-off-by: jayant chauhan <0001jayant@gmail.com>
@philberty
Copy link
Member

actually this is hiding a code gen bug it shouldnt merge this unless we understand why an error mark node has crept into the IR

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 check_decl, at rust/checks/lints/rust-lint-unused-var.cc:28

3 participants