aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/optimize.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2016-11-01 21:50:29 -0400
committerJason Merrill <jason@gcc.gnu.org>2016-11-01 21:50:29 -0400
commit31f7f784fe7fa68bca218df43ec8965569d6cb5d (patch)
tree1dffc88ff5b0ae93ef01f8ea3bba2713ee747362 /gcc/cp/optimize.c
parentbe9f7afb32b8cf2dfb6d08f86804b6eabd30c838 (diff)
downloadgcc-31f7f784fe7fa68bca218df43ec8965569d6cb5d.zip
gcc-31f7f784fe7fa68bca218df43ec8965569d6cb5d.tar.gz
gcc-31f7f784fe7fa68bca218df43ec8965569d6cb5d.tar.bz2
Implement P0136R1, Rewording inheriting constructors.
gcc/c-family/ * c.opt (-fnew-inheriting-ctors): New. * c-opts.c: Default to on for ABI 11+. gcc/cp/ * call.c (enum rejection_reason_code): Add rr_inherited_ctor. (inherited_ctor_rejection): New. (add_function_candidate): Reject inherited ctors for copying. (enforce_access): Use strip_inheriting_ctors. (print_z_candidate): Likewise. Handle rr_inherited_ctor. (convert_like_real): Avoid copying inheriting ctor parameters. (build_over_call): Likewise. A base ctor inheriting from vbase has no parms. Sorry about varargs. (joust): A local constructor beats inherited with the same convs. * class.c (add_method): Handle hiding inheriting ctors. (one_inherited_ctor): Handle new semantics. (add_implicitly_declared_members): Pass using_decl down. (build_clone): A base ctor inheriting from vbase has no parms. * cp-tree.h (DECL_INHERITED_CTOR): Store this instead of the base. (SET_DECL_INHERITED_CTOR): Likewise. (DECL_INHERITED_CTOR_BASE): Adjust. * constexpr.c: Adjust. * error.c (dump_function_decl): Decorate inheriting ctors. * init.c (emit_mem_initializers): Suppress access control in inheriting ctor. * mangle.c (write_special_name_constructor): Handle new inheriting ctor mangling. * method.c (strip_inheriting_ctors, inherited_ctor_binfo) (ctor_omit_inherited_parms, binfo_inherited_from): New. (synthesized_method_walk): Use binfo_inherited_from. Suppress access control in inheriting ctor. (deduce_inheriting_ctor): Deleted if ambiguous ctor inheritance. (maybe_explain_implicit_delete): Explain ambigous ctor inheritance. (add_one_base_init, do_build_copy_constructor): Adjust. (locate_fn_flags, explain_implicit_non_constexpr): Adjust. (implicitly_declare_fn): Adjust. (get_inherited_ctor): Remove. * name-lookup.c (do_class_using_decl): Check for indirect ctor inheritance. * optimize.c (cdtor_comdat_group): Adjust for new mangling. (maybe_clone_body): Handle omitted parms in base clone. (maybe_thunk_body): Don't thunk if base clone omits parms. * pt.c (tsubst_decl): Adjust. (instantiate_template_1): Suppress access control in inheriting ctor. (fn_type_unification): Do deduction with inherited ctor. * tree.c (special_function_p): Adjust. gcc/ * tree-inline.c (copy_tree_body_r): Only copy the taken branch of a COND_EXPR with constant condition. libiberty/ * cp-demangle.c (d_ctor_dtor_name): Handle inheriting constructor. From-SVN: r241765
Diffstat (limited to 'gcc/cp/optimize.c')
-rw-r--r--gcc/cp/optimize.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index e2032c1..b926ef7 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -166,7 +166,8 @@ cdtor_comdat_group (tree complete, tree base)
{
gcc_assert (!diff_seen
&& idx > 0
- && (p[idx - 1] == 'C' || p[idx - 1] == 'D')
+ && (p[idx - 1] == 'C' || p[idx - 1] == 'D'
+ || p[idx - 1] == 'I')
&& p[idx] == '1'
&& q[idx] == '2');
grp_name[idx] = '5';
@@ -259,6 +260,11 @@ maybe_thunk_body (tree fn, bool force)
(for non-vague linkage ctors) or the COMDAT group (otherwise). */
populate_clone_array (fn, fns);
+
+ /* Don't use thunks if the base clone omits inherited parameters. */
+ if (ctor_omit_inherited_parms (fns[0]))
+ return 0;
+
DECL_ABSTRACT_P (fn) = false;
if (!DECL_WEAK (fn))
{
@@ -490,7 +496,7 @@ maybe_clone_body (tree fn)
parm = DECL_CHAIN (parm);
if (DECL_HAS_VTT_PARM_P (clone))
clone_parm = DECL_CHAIN (clone_parm);
- for (; parm;
+ for (; parm && clone_parm;
parm = DECL_CHAIN (parm), clone_parm = DECL_CHAIN (clone_parm))
/* Update this parameter. */
update_cloned_parm (parm, clone_parm, first);
@@ -616,7 +622,8 @@ maybe_clone_body (tree fn)
else
{
decl_map->put (parm, clone_parm);
- clone_parm = DECL_CHAIN (clone_parm);
+ if (clone_parm)
+ clone_parm = DECL_CHAIN (clone_parm);
}
}