]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Change dfs function return type to support gcc 4.8
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 26 Mar 2024 15:32:31 +0000 (16:32 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 1 Aug 2024 14:52:28 +0000 (16:52 +0200)
GCC 4.8 does not handle pair with references correctly. We need to use a
properly typed struct instead.

gcc/rust/ChangeLog:

* resolve/rust-forever-stack.h: Change dfs function prototype and
declare dfs return type structure.
* resolve/rust-forever-stack.hxx: Adapt dfs function to the new return
type.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/resolve/rust-forever-stack.h
gcc/rust/resolve/rust-forever-stack.hxx

index 3dab45e7e779b4f1d9dad8416360c6a1b3a99937..72b96bff3b3f06c0d03bd023cd37548c3cfc39a6 100644 (file)
@@ -596,10 +596,14 @@ private:
                                         SegIterator<S> iterator);
 
   /* Helper functions for forward resolution (to_canonical_path, to_rib...) */
+  struct DfsResult
+  {
+    Node &first;
+    std::string second;
+  };
 
   // FIXME: Documentation
-  tl::optional<std::pair<Node &, std::string>> dfs (Node &starting_point,
-                                                   NodeId to_find);
+  tl::optional<DfsResult> dfs (Node &starting_point, NodeId to_find);
   // FIXME: Documentation
   tl::optional<Rib &> dfs_rib (Node &starting_point, NodeId to_find);
 };
index 6b622b8aef1e87cc3dc060ab3a30abbfdba2b55d..2c3cba5944842d7d8a5765931ef338b5fef67b33 100644 (file)
@@ -468,7 +468,7 @@ ForeverStack<N>::resolve_path (const std::vector<S> &segments)
 }
 
 template <Namespace N>
-tl::optional<std::pair<typename ForeverStack<N>::Node &, std::string>>
+tl::optional<typename ForeverStack<N>::DfsResult>
 ForeverStack<N>::dfs (ForeverStack<N>::Node &starting_point, NodeId to_find)
 {
   auto values = starting_point.rib.get_values ();
@@ -498,7 +498,7 @@ ForeverStack<N>::to_canonical_path (NodeId id)
   // back up to the root (parent().parent().parent()...) accumulate link
   // segments reverse them that's your canonical path
 
-  return dfs (root, id).map ([this, id] (std::pair<Node &, std::string> tuple) {
+  return dfs (root, id).map ([this, id] (DfsResult tuple) {
     auto containing_node = tuple.first;
     auto name = tuple.second;