aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/method.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2001-07-05 11:39:36 -0400
committerJason Merrill <jason@gcc.gnu.org>2001-07-05 11:39:36 -0400
commit01f9e964bd55fd0f52f4a084f70ee7a5e071cfa9 (patch)
tree0709114363ae3b357e7e3dc92f90a62a000a2673 /gcc/cp/method.c
parent021c4bfd955ee14e054e0af78941e7401dbb9012 (diff)
downloadgcc-01f9e964bd55fd0f52f4a084f70ee7a5e071cfa9.zip
gcc-01f9e964bd55fd0f52f4a084f70ee7a5e071cfa9.tar.gz
gcc-01f9e964bd55fd0f52f4a084f70ee7a5e071cfa9.tar.bz2
cvt.c (convert_lvalue): New fn.
* cvt.c (convert_lvalue): New fn. * cp-tree.h: Declare it. * method.c (do_build_assign_ref): Use it. (do_build_copy_constructor): Convert parm to base types before calling base constructors. * typeck.c (check_return_expr): Check DECL_ALIGN instead of DECL_USER_ALIGN. Check flag_elide_constructors instead of optimize. * semantics.c (cp_expand_stmt): Don't destroy the named return value. From-SVN: r43780
Diffstat (limited to 'gcc/cp/method.c')
-rw-r--r--gcc/cp/method.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index ceb569c..6f6a14b 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -557,25 +557,31 @@ do_build_copy_constructor (fndecl)
int cvquals = CP_TYPE_QUALS (TREE_TYPE (parm));
int i;
- /* Initialize all the base-classes. */
+ /* Initialize all the base-classes with the parameter converted to
+ their type so that we get their copy constructor and not another
+ constructor that takes current_class_type. */
for (t = CLASSTYPE_VBASECLASSES (current_class_type); t;
t = TREE_CHAIN (t))
- base_init_list
- = tree_cons (BINFO_TYPE (TREE_VALUE (t)), parm,
- base_init_list);
+ {
+ tree type = BINFO_TYPE (TREE_VALUE (t));
+ base_init_list = tree_cons (type, convert_lvalue (type, parm),
+ base_init_list);
+ }
+
for (i = 0; i < n_bases; ++i)
{
t = TREE_VEC_ELT (binfos, i);
if (TREE_VIA_VIRTUAL (t))
continue;
- base_init_list
- = tree_cons (BINFO_TYPE (t), parm, base_init_list);
+ t = BINFO_TYPE (t);
+ base_init_list = tree_cons (t, convert_lvalue (t, parm),
+ base_init_list);
}
for (; fields; fields = TREE_CHAIN (fields))
{
- tree init, t;
+ tree init;
tree field = fields;
if (TREE_CODE (field) != FIELD_DECL)
@@ -645,12 +651,7 @@ do_build_assign_ref (fndecl)
for (i = 0; i < n_bases; ++i)
{
tree basetype = BINFO_TYPE (TREE_VEC_ELT (binfos, i));
- tree p = build_qualified_type (basetype, cvquals);
-
- p = convert_to_reference
- (build_reference_type (p), parm,
- CONV_IMPLICIT, LOOKUP_COMPLAIN, NULL_TREE);
- p = convert_from_reference (p);
+ tree p = convert_lvalue (basetype, parm);
p = build_member_call (basetype, ansi_assopname (NOP_EXPR),
build_tree_list (NULL_TREE, p));
finish_expr_stmt (p);