diff options
author | Philip Herron <herron.philip@googlemail.com> | 2025-03-28 17:42:07 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2025-03-28 18:34:27 +0000 |
commit | 8d1c01c818428a432dc7a64237bdf62aa3fd0c6c (patch) | |
tree | 1a298e20124fe07e3ce6ffc265eea42091e72583 /gcc | |
parent | a0b21c94157d85f4ab87aa9aee83cb629678f72a (diff) | |
download | gcc-8d1c01c818428a432dc7a64237bdf62aa3fd0c6c.zip gcc-8d1c01c818428a432dc7a64237bdf62aa3fd0c6c.tar.gz gcc-8d1c01c818428a432dc7a64237bdf62aa3fd0c6c.tar.bz2 |
gccrs: FIX ICE when working with HIR::BareFunctionType
Fixes Rust-GCC#3615
gcc/rust/ChangeLog:
* hir/rust-hir-dump.cc (Dump::visit): check has type
* hir/tree/rust-hir-type.cc (BareFunctionType::BareFunctionType): likewise
gcc/testsuite/ChangeLog:
* rust/compile/issue-3615.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/hir/rust-hir-dump.cc | 4 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-type.cc | 3 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/issue-3615.rs | 7 |
3 files changed, 12 insertions, 2 deletions
diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc index 983922c..b6dcf18 100644 --- a/gcc/rust/hir/rust-hir-dump.cc +++ b/gcc/rust/hir/rust-hir-dump.cc @@ -2440,7 +2440,9 @@ Dump::visit (BareFunctionType &e) end_field ("params"); } - visit_field ("return_type", e.get_return_type ()); + if (e.has_return_type ()) + visit_field ("return_type", e.get_return_type ()); + put_field ("is_variadic", std::to_string (e.get_is_variadic ())); end ("BareFunctionType"); } diff --git a/gcc/rust/hir/tree/rust-hir-type.cc b/gcc/rust/hir/tree/rust-hir-type.cc index 689d86b..6a6c319 100644 --- a/gcc/rust/hir/tree/rust-hir-type.cc +++ b/gcc/rust/hir/tree/rust-hir-type.cc @@ -268,7 +268,8 @@ BareFunctionType::BareFunctionType (BareFunctionType const &other) for_lifetimes (other.for_lifetimes), function_qualifiers (other.function_qualifiers), params (other.params), is_variadic (other.is_variadic), - return_type (other.return_type->clone_type ()) + return_type (other.has_return_type () ? other.return_type->clone_type () + : nullptr) {} BareFunctionType & diff --git a/gcc/testsuite/rust/compile/issue-3615.rs b/gcc/testsuite/rust/compile/issue-3615.rs new file mode 100644 index 0000000..e5c5072 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3615.rs @@ -0,0 +1,7 @@ +pub trait Trait { + pub fn nrvo(init: fn()) -> [u8; 4096] { + let mut buf = [0; 4096]; + + buf + } +} |