aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-07-18 16:22:44 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-08-05 16:36:56 +0200
commitc3642a2cded7b6e8c92d065fff890653d02a15ad (patch)
treede39de5d15bf8bbd9816354be7d0b2a8fce56151 /gcc/testsuite/rust
parentcfa1e8f973cb89ef31c2f265d978f37c0f72ab9b (diff)
downloadgcc-c3642a2cded7b6e8c92d065fff890653d02a15ad.zip
gcc-c3642a2cded7b6e8c92d065fff890653d02a15ad.tar.gz
gcc-c3642a2cded7b6e8c92d065fff890653d02a15ad.tar.bz2
gccrs: Fix ICE with duplicate root item main function
Rust seems to allow duplicate HIR::Item 'main' functions but it needs to be a root item to be the true main entry point. This means we can use the canonical path to determine if this is a root one where its CrateName::main or CrateName::Module::main. Fixes Rust-GCC#3978 gcc/rust/ChangeLog: * backend/rust-compile-base.cc: check the canonical path gcc/testsuite/ChangeLog: * rust/compile/issue-3978.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/testsuite/rust')
-rw-r--r--gcc/testsuite/rust/compile/issue-3978.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/issue-3978.rs b/gcc/testsuite/rust/compile/issue-3978.rs
new file mode 100644
index 0000000..4f17d3d
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3978.rs
@@ -0,0 +1,8 @@
+type Dimension = usize;
+
+pub fn main() {}
+
+mod m2 {
+ fn main() {}
+ // { dg-warning "function is never used" "" { target *-*-* } .-1 }
+}