FreeBSD/contrib/gcc/cp/name-lookup.c
/* Combines two sets of overloaded functions into an OVERLOAD chain, removing
   duplicates.  The first list becomes the tail of the result.

   The algorithm is O(n^2).  We could get this down to O(n log n) by
   doing a sort on the addresses of the functions, if that becomes
   necessary.  */
Combines two sets of overloaded functions into an OVERLOAD chain, removing
duplicates.  The first list becomes the tail of the result.


Combines two sets of overloaded functions into an OVERLOAD chain removing duplicates . The first list becomes the tail of the result .
static tree
merge_functions (tree s1, tree s2)
{
  for (; s2; s2 = OVL_NEXT (s2))
    {
      tree fn2 = OVL_CURRENT (s2);
      tree fns1;
      for (fns1 = s1; fns1; fns1 = OVL_NEXT (fns1))
	{
	  tree fn1 = OVL_CURRENT (fns1);
	  if (fn1 == fn2
	      || (DECL_EXTERN_C_P (fn1) && DECL_EXTERN_C_P (fn2)
		  && DECL_NAME (fn1) == DECL_NAME (fn2)))
	    break;
	}
      if (!fns1)
	s1 = build_overload (fn2, s1);
    }
  return s1;
}
static tree merge_functions ( tree s1 , tree s2 ) { for ( ; s2 ; s2 = OVL_NEXT ( s2 ) ) { tree fn2 = OVL_CURRENT ( s2 ) ; tree fns1 ; for ( fns1 = s1 ; fns1 ; fns1 = OVL_NEXT ( fns1 ) ) { tree fn1 = OVL_CURRENT ( fns1 ) ; if ( fn1 == fn2 || ( DECL_EXTERN_C_P ( fn1 ) && DECL_EXTERN_C_P ( fn2 ) && DECL_NAME ( fn1 ) == DECL_NAME ( fn2 ) ) ) break ; } if ( ! fns1 ) s1 = build_overload ( fn2 , s1 ) ; } return s1 ; }
Combines two sets of overloaded functions into an OVERLOAD chain, removing
duplicates.
Combines two sets of overloaded functions into an OVERLOAD chain removing duplicates .
/* If the function from S2 is already in S1, there is no
	     need to add it again.  For `extern "C"' functions, we
	     might have two FUNCTION_DECLs for the same function, in
	     different namespaces; again, we only need one of them.  */ /* If we exhausted all of the functions in S1, FN2 is new.  */