Skip to content

Commit 65f283d

Browse files
committed
Change dfs function return type to support gcc 4.8
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>
1 parent 2ac4591 commit 65f283d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

gcc/rust/resolve/rust-forever-stack.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,14 @@ template <Namespace N> class ForeverStack
596596
SegIterator<S> iterator);
597597

598598
/* Helper functions for forward resolution (to_canonical_path, to_rib...) */
599+
struct DfsResult
600+
{
601+
Node &first;
602+
std::string second;
603+
};
599604

600605
// FIXME: Documentation
601-
tl::optional<std::pair<Node &, std::string>> dfs (Node &starting_point,
602-
NodeId to_find);
606+
tl::optional<DfsResult> dfs (Node &starting_point, NodeId to_find);
603607
// FIXME: Documentation
604608
tl::optional<Rib &> dfs_rib (Node &starting_point, NodeId to_find);
605609
};

gcc/rust/resolve/rust-forever-stack.hxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ ForeverStack<N>::resolve_path (const std::vector<S> &segments)
468468
}
469469

470470
template <Namespace N>
471-
tl::optional<std::pair<typename ForeverStack<N>::Node &, std::string>>
471+
tl::optional<typename ForeverStack<N>::DfsResult>
472472
ForeverStack<N>::dfs (ForeverStack<N>::Node &starting_point, NodeId to_find)
473473
{
474474
auto values = starting_point.rib.get_values ();
@@ -498,7 +498,7 @@ ForeverStack<N>::to_canonical_path (NodeId id)
498498
// back up to the root (parent().parent().parent()...) accumulate link
499499
// segments reverse them that's your canonical path
500500

501-
return dfs (root, id).map ([this, id] (std::pair<Node &, std::string> tuple) {
501+
return dfs (root, id).map ([this, id] (DfsResult tuple) {
502502
auto containing_node = tuple.first;
503503
auto name = tuple.second;
504504

0 commit comments

Comments
 (0)