Skip to content

Commit

Permalink
Change dfs function return type to support gcc 4.8
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
P-E-P committed Mar 26, 2024
1 parent 2ac4591 commit 65f283d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions gcc/rust/resolve/rust-forever-stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,10 +596,14 @@ template <Namespace N> class ForeverStack
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);
};
Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/resolve/rust-forever-stack.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 65f283d

Please sign in to comment.