From 34b0a681598d52de442a0a21c3a7df20bf1485bc Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Wed, 26 Mar 2025 17:26:12 +0000 Subject: gccrs: Fix ICE when using super mid way though path Fixes Rust-GCC#3568 gcc/rust/ChangeLog: * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): check for super mid path gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: nr2 puts out a different error multiple times * rust/compile/issue-3568.rs: New test. Signed-off-by: Philip Herron --- gcc/rust/resolve/rust-ast-resolve-path.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/rust/resolve') diff --git a/gcc/rust/resolve/rust-ast-resolve-path.cc b/gcc/rust/resolve/rust-ast-resolve-path.cc index b2b1071..530926d 100644 --- a/gcc/rust/resolve/rust-ast-resolve-path.cc +++ b/gcc/rust/resolve/rust-ast-resolve-path.cc @@ -370,6 +370,12 @@ ResolvePath::resolve_path (AST::SimplePath &expr) } else if (segment.is_super_path_seg ()) { + if (!is_first_segment) + { + rust_error_at (segment.get_locus (), + "% can only be used in start position"); + return UNKNOWN_NODEID; + } if (module_scope_id == crate_scope_id) { rust_error_at (segment.get_locus (), -- cgit v1.1