Skip to content

Commit 34b0a68

Browse files
committed
gccrs: Fix ICE when using super mid way though path
Fixes #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 <[email protected]>
1 parent 6c14a3b commit 34b0a68

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

gcc/rust/resolve/rust-ast-resolve-path.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,12 @@ ResolvePath::resolve_path (AST::SimplePath &expr)
370370
}
371371
else if (segment.is_super_path_seg ())
372372
{
373+
if (!is_first_segment)
374+
{
375+
rust_error_at (segment.get_locus (),
376+
"%<super%> can only be used in start position");
377+
return UNKNOWN_NODEID;
378+
}
373379
if (module_scope_id == crate_scope_id)
374380
{
375381
rust_error_at (segment.get_locus (),
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pub type T = ();
2+
mod foo {
3+
pub use super::T;
4+
}
5+
6+
pub use foo::super::foo::S as T;
7+
// { dg-error ".super. can only be used in start position" "" { target *-*-* } .-1 }

gcc/testsuite/rust/compile/nr2/exclude

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ torture/alt_patterns1.rs
3636
torture/loop4.rs
3737
torture/loop8.rs
3838
torture/name_resolve1.rs
39+
issue-3568.rs
3940
# please don't delete the trailing newline

0 commit comments

Comments
 (0)