]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add null check to reconstruct
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Mon, 18 Aug 2025 08:47:56 +0000 (10:47 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 30 Oct 2025 19:58:41 +0000 (20:58 +0100)
gcc/rust/ChangeLog:

* ast/rust-type.h: Prevent reconstruction on null pointers.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ast/rust-type.h

index f2502d74501fd47d9d097c022d001a86d8c431ef..8d6c3e5166fc947cf0ba57e5bba412df94ace69e 100644 (file)
@@ -1048,10 +1048,14 @@ public:
 
   BareFunctionType *reconstruct_impl () const override
   {
+    std::unique_ptr<TypeNoBounds> ret_type = nullptr;
+    if (return_type != nullptr)
+      ret_type = return_type->reconstruct ();
+
     return new BareFunctionType (
       for_lifetimes, function_qualifiers, params,
       /* FIXME: Should params be reconstruct() as well? */
-      _is_variadic, variadic_attrs, return_type->reconstruct (), locus);
+      _is_variadic, variadic_attrs, std::move (ret_type), locus);
   }
 
 protected: