diff options
Diffstat (limited to 'contrib/gcc/cp/call.c')
-rw-r--r-- | contrib/gcc/cp/call.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/contrib/gcc/cp/call.c b/contrib/gcc/cp/call.c index ac7aeb8..8750128 100644 --- a/contrib/gcc/cp/call.c +++ b/contrib/gcc/cp/call.c @@ -4527,12 +4527,17 @@ build_over_call (cand, args, flags) TREE_VALUE (arg), cand->conversion_path, 1); + /* Check that the base class is accessible. */ + if (!accessible_base_p (TREE_TYPE (argtype), + BINFO_TYPE (cand->conversion_path))) + error ("`%T' is not an accessible base of `%T'", + BINFO_TYPE (cand->conversion_path), + TREE_TYPE (argtype)); /* If fn was found by a using declaration, the conversion path will be to the derived class, not the base declaring fn. We must convert from derived to base. */ base_binfo = lookup_base (TREE_TYPE (TREE_TYPE (converted_arg)), TREE_TYPE (parmtype), ba_ignore, NULL); - converted_arg = build_base_path (PLUS_EXPR, converted_arg, base_binfo, 1); @@ -4857,11 +4862,23 @@ build_special_member_call (tree instance, tree name, tree args, TREE_TYPE (instance) = build_pointer_type (class_type); instance = build1 (INDIRECT_REF, class_type, instance); } - else if (name == complete_dtor_identifier - || name == base_dtor_identifier - || name == deleting_dtor_identifier) - my_friendly_assert (args == NULL_TREE, 20020712); + else + { + if (name == complete_dtor_identifier + || name == base_dtor_identifier + || name == deleting_dtor_identifier) + my_friendly_assert (args == NULL_TREE, 20020712); + /* We must perform the conversion here so that we do not + subsequently check to see whether BINFO is an accessible + base. (It is OK for a constructor to call a constructor in + an inaccessible base as long as the constructor being called + is accessible.) */ + if (!same_type_ignoring_top_level_qualifiers_p + (TREE_TYPE (instance), BINFO_TYPE (binfo))) + instance = convert_to_base_statically (instance, binfo); + } + my_friendly_assert (instance != NULL_TREE, 20020712); /* Resolve the name. */ @@ -4899,7 +4916,9 @@ build_special_member_call (tree instance, tree name, tree args, args = tree_cons (NULL_TREE, sub_vtt, args); } - return build_new_method_call (instance, fns, args, binfo, flags); + return build_new_method_call (instance, fns, args, + TYPE_BINFO (BINFO_TYPE (binfo)), + flags); } /* Build a call to "INSTANCE.FN (ARGS)". */ |