Commit a489b1f0 by Richard Guenther Committed by Richard Biener

re PR c++/22369 (C++ produces mis-matched types with pointers to member functions)

2007-08-20  Richard Guenther  <rguenther@suse.de>

	PR c++/22369
	PR c++/22451
        * call.c (build_new_method_call): Convert initializer to
        the basetype.
        * init.c (build_aggr_init): Do not fiddle with types.
        (build_vec_delete_1): Use correct type for POINTER_PLUS_EXPR.
        * except.c (build_throw): Do not drop qualifiers for the
        pointer type.
        * typeck.c (get_member_function_from_ptrfunc): Do not
        fiddle with types, instead convert.
        (build_ptrmemfunc1): Convert to the target type for
        initialization.
        (gfc_trans_allocate): Convert result to target type.
	* cp-objcp-common.c (cxx_get_alias_set): Pointers to
	pointer-to-member structures shall have alias set zero as well.

From-SVN: r127647
parent ff7637ef
2007-08-20 Richard Guenther <rguenther@suse.de>
PR c++/22369
PR c++/22451
* call.c (build_new_method_call): Convert initializer to
the basetype.
* init.c (build_aggr_init): Do not fiddle with types.
(build_vec_delete_1): Use correct type for POINTER_PLUS_EXPR.
* except.c (build_throw): Do not drop qualifiers for the
pointer type.
* typeck.c (get_member_function_from_ptrfunc): Do not
fiddle with types, instead convert.
(build_ptrmemfunc1): Convert to the target type for
initialization.
(gfc_trans_allocate): Convert result to target type.
* cp-objcp-common.c (cxx_get_alias_set): Pointers to
pointer-to-member structures shall have alias set zero as well.
2007-08-20 Richard Guenther <rguenther@suse.de>
* cp-objcp-common.h (LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P):
Remove.
* cp-tree.h (cp_auto_var_in_fn_p): Remove.
......
......@@ -5514,15 +5514,18 @@ build_new_method_call (tree instance, tree fns, tree args,
instance_ptr = build_this (instance);
/* It's OK to call destructors on cv-qualified objects. Therefore,
convert the INSTANCE_PTR to the unqualified type, if necessary. */
if (DECL_DESTRUCTOR_P (fn))
/* It's OK to call destructors and constructors on cv-qualified objects.
Therefore, convert the INSTANCE_PTR to the unqualified type, if
necessary. */
if (DECL_DESTRUCTOR_P (fn)
|| DECL_CONSTRUCTOR_P (fn))
{
tree type = build_pointer_type (basetype);
if (!same_type_p (type, TREE_TYPE (instance_ptr)))
instance_ptr = build_nop (type, instance_ptr);
name = complete_dtor_identifier;
}
if (DECL_DESTRUCTOR_P (fn))
name = complete_dtor_identifier;
class_type = (conversion_path ? BINFO_TYPE (conversion_path) : NULL_TREE);
mem_args = tree_cons (NULL_TREE, instance_ptr, args);
......
......@@ -44,7 +44,9 @@ cxx_get_alias_set (tree t)
return get_alias_set (TYPE_CONTEXT (t));
/* Punt on PMFs until we canonicalize functions properly. */
if (TYPE_PTRMEMFUNC_P (t))
if (TYPE_PTRMEMFUNC_P (t)
|| (POINTER_TYPE_P (t)
&& TYPE_PTRMEMFUNC_P (TREE_TYPE (t))))
return 0;
return c_common_get_alias_set (t);
......
......@@ -682,7 +682,7 @@ build_throw (tree exp)
respectively. */
temp_type = is_bitfield_expr_with_lowered_type (exp);
if (!temp_type)
temp_type = type_decays_to (TYPE_MAIN_VARIANT (TREE_TYPE (exp)));
temp_type = type_decays_to (TREE_TYPE (exp));
/* OK, this is kind of wacky. The standard says that we call
terminate when the exception handling mechanism, after
......
......@@ -1134,7 +1134,6 @@ build_aggr_init (tree exp, tree init, int flags)
/* Just know that we've seen something for this node. */
TREE_USED (exp) = 1;
TREE_TYPE (exp) = TYPE_MAIN_VARIANT (type);
is_global = begin_init_stmts (&stmt_expr, &compound_stmt);
destroy_temps = stmts_are_full_exprs_p ();
current_stmt_tree ()->stmts_are_full_exprs_p = 0;
......@@ -1142,7 +1141,6 @@ build_aggr_init (tree exp, tree init, int flags)
init, LOOKUP_NORMAL|flags);
stmt_expr = finish_init_stmts (is_global, stmt_expr, compound_stmt);
current_stmt_tree ()->stmts_are_full_exprs_p = destroy_temps;
TREE_TYPE (exp) = type;
TREE_READONLY (exp) = was_const;
TREE_THIS_VOLATILE (exp) = was_volatile;
......@@ -2320,7 +2318,7 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
tbase = create_temporary_var (ptype);
tbase_init = build_modify_expr (tbase, NOP_EXPR,
fold_build2 (POINTER_PLUS_EXPR, ptype,
base,
fold_convert (ptype, base),
virtual_size));
DECL_REGISTER (tbase) = 1;
controller = build3 (BIND_EXPR, void_type_node, tbase,
......
......@@ -2646,7 +2646,7 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function)
e2 = build1 (NOP_EXPR, TREE_TYPE (e2),
build_unary_op (ADDR_EXPR, e2, /*noconvert=*/1));
TREE_TYPE (e2) = TREE_TYPE (e3);
e2 = fold_convert (TREE_TYPE (e3), e2);
e1 = build_conditional_expr (e1, e2, e3);
/* Make sure this doesn't get evaluated first inside one of the
......@@ -6056,6 +6056,9 @@ build_ptrmemfunc1 (tree type, tree delta, tree pfn)
/* Make sure DELTA has the type we want. */
delta = convert_and_check (delta_type_node, delta);
/* Convert to the correct target type if necessary. */
pfn = fold_convert (TREE_TYPE (pfn_field), pfn);
/* Finish creating the initializer. */
v = VEC_alloc(constructor_elt, gc, 2);
CONSTRUCTOR_APPEND_ELT(v, pfn_field, pfn);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment