tree binfo_or_else (tree base, tree type) { tree binfo = lookup_base (type, base, ba_unique, NULL); if (binfo == error_mark_node) return NULL_TREE; else if (!binfo) error_not_base_type (base, type); return binfo; }
static tree build_up_reference (tree type, tree arg, int flags, tree decl) { tree rval; tree argtype = TREE_TYPE (arg); tree target_type = TREE_TYPE (type); gcc_assert (TREE_CODE (type) == REFERENCE_TYPE); if ((flags & DIRECT_BIND) && ! real_lvalue_p (arg)) { /* Create a new temporary variable. We can't just use a TARGET_EXPR here because it needs to live as long as DECL. */ tree targ = arg; arg = make_temporary_var_for_ref_to_temp (decl, TREE_TYPE (arg)); /* Process the initializer for the declaration. */ DECL_INITIAL (arg) = targ; cp_finish_decl (arg, targ, /*init_const_expr_p=*/false, NULL_TREE, LOOKUP_ONLYCONVERTING|DIRECT_BIND); } else if (!(flags & DIRECT_BIND) && ! lvalue_p (arg)) return get_target_expr (arg); /* If we had a way to wrap this up, and say, if we ever needed its address, transform all occurrences of the register, into a memory reference we could win better. */ rval = cp_build_unary_op (ADDR_EXPR, arg, 1, tf_warning_or_error); if (rval == error_mark_node) return error_mark_node; if ((flags & LOOKUP_PROTECT) && TYPE_MAIN_VARIANT (argtype) != TYPE_MAIN_VARIANT (target_type) && MAYBE_CLASS_TYPE_P (argtype) && MAYBE_CLASS_TYPE_P (target_type)) { /* We go through lookup_base for the access control. */ tree binfo = lookup_base (argtype, target_type, ba_check, NULL); if (binfo == error_mark_node) return error_mark_node; if (binfo == NULL_TREE) return error_not_base_type (target_type, argtype); rval = build_base_path (PLUS_EXPR, rval, binfo, 1); } else rval = convert_to_pointer_force (build_pointer_type (target_type), rval); return build_nop (type, rval); }