contrib/gcc-4.4/gcc/cp/call.c
/* Return the implicit conversion sequence that could be used to
   convert E1 to E2 in [expr.cond].  */
Return the implicit conversion sequence that could be used to
convert E1 to E2 in [expr.cond].
Return the implicit conversion sequence that could be used to convert E1 to E2 in [ expr . cond ] .
static conversion *
conditional_conversion (tree e1, tree e2)
{
  tree t1 = non_reference (TREE_TYPE (e1));
  tree t2 = non_reference (TREE_TYPE (e2));
  conversion *conv;
  bool good_base;
  if (real_lvalue_p (e2))
    {
      conv = implicit_conversion (build_reference_type (t2),
				  t1,
				  e1,
				  false,
				  LOOKUP_NO_TEMP_BIND);
      if (conv)
	return conv;
    }
  if (CLASS_TYPE_P (t1) && CLASS_TYPE_P (t2)
      && ((good_base = DERIVED_FROM_P (t2, t1)) || DERIVED_FROM_P (t1, t2)))
    {
      if (good_base && at_least_as_qualified_p (t2, t1))
	{
	  conv = build_identity_conv (t1, e1);
	  if (!same_type_p (TYPE_MAIN_VARIANT (t1),
			    TYPE_MAIN_VARIANT (t2)))
	    conv = build_conv (ck_base, t2, conv);
	  else
	    conv = build_conv (ck_rvalue, t2, conv);
	  return conv;
	}
      else
	return NULL;
    }
  else
    return implicit_conversion (t2, t1, e1, false,
				LOOKUP_NORMAL);
}
static conversion * conditional_conversion ( tree e1 , tree e2 ) { tree t1 = non_reference ( TREE_TYPE ( e1 ) ) ; tree t2 = non_reference ( TREE_TYPE ( e2 ) ) ; conversion * conv ; bool good_base ; if ( real_lvalue_p ( e2 ) ) { conv = implicit_conversion ( build_reference_type ( t2 ) , t1 , e1 , false , LOOKUP_NO_TEMP_BIND ) ; if ( conv ) return conv ; } if ( CLASS_TYPE_P ( t1 ) && CLASS_TYPE_P ( t2 ) && ( ( good_base = DERIVED_FROM_P ( t2 , t1 ) ) || DERIVED_FROM_P ( t1 , t2 ) ) ) { if ( good_base && at_least_as_qualified_p ( t2 , t1 ) ) { conv = build_identity_conv ( t1 , e1 ) ; if ( ! same_type_p ( TYPE_MAIN_VARIANT ( t1 ) , TYPE_MAIN_VARIANT ( t2 ) ) ) conv = build_conv ( ck_base , t2 , conv ) ; else conv = build_conv ( ck_rvalue , t2 , conv ) ; return conv ; } else return NULL ; } else return implicit_conversion ( t2 , t1 , e1 , false , LOOKUP_NORMAL ) ; }
Return the implicit conversion sequence that could be used to
convert E1 to E2 in [expr.cond].
Return the implicit conversion sequence that could be used to convert E1 to E2 in [ expr . cond ] .
/* [expr.cond]

     If E2 is an lvalue: E1 can be converted to match E2 if E1 can be
     implicitly converted (clause _conv_) to the type "reference to
     T2", subject to the constraint that in the conversion the
     reference must bind directly (_dcl.init.ref_) to E1.  */ /*c_cast_p=*/ /* [expr.cond]

     If E1 and E2 have class type, and the underlying class types are
     the same or one is a base class of the other: E1 can be converted
     to match E2 if the class of T2 is the same type as, or a base
     class of, the class of T1, and the cv-qualification of T2 is the
     same cv-qualification as, or a greater cv-qualification than, the
     cv-qualification of T1.  If the conversion is applied, E1 is
     changed to an rvalue of type T2 that still refers to the original
     source class object (or the appropriate subobject thereof).  */ /* [expr.cond]

       Otherwise: E1 can be converted to match E2 if E1 can be implicitly
       converted to the type that expression E2 would have if E2 were
       converted to an rvalue (or the type it has, if E2 is an rvalue).  */ /*c_cast_p=*/