From 200e869c8f2ce63376d5985f3f1030c1d1ca869f Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Fri, 19 Feb 2016 17:04:29 +0000 Subject: [PATCH] Adjust fix PR c++/68948 gcc/cp/ChangeLog: PR c++/68948 * pt.c (tsubst_baselink): Don't diagnose an invalid constructor call here. * semantics.c (finish_call_expr): Don't assume a constructor call is dependent if only the "this" pointer is dependent. When building a constructor call, always use a dummy object. From-SVN: r233563 --- gcc/cp/ChangeLog | 9 +++++++++ gcc/cp/pt.c | 10 +--------- gcc/cp/semantics.c | 13 +++++++++++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dbc674113f86..8f9b0be1327c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2016-02-19 Patrick Palka + + PR c++/68948 + * pt.c (tsubst_baselink): Don't diagnose an invalid constructor + call here. + * semantics.c (finish_call_expr): Don't assume a constructor + call is dependent if only the "this" pointer is dependent. When + building a constructor call, always use a dummy object. + 2016-02-19 Jakub Jelinek PR c++/69850 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a55dc10fdfc1..730838922c7c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13603,15 +13603,7 @@ tsubst_baselink (tree baselink, tree object_type, name = mangle_conv_op_name_for_type (optype); baselink = lookup_fnfields (qualifying_scope, name, /*protect=*/1); if (!baselink) - { - if (constructor_name_p (name, qualifying_scope)) - { - if (complain & tf_error) - error ("cannot call constructor %<%T::%D%> directly", - qualifying_scope, name); - } - return error_mark_node; - } + return error_mark_node; /* If lookup found a single function, mark it as used at this point. (If it lookup found multiple functions the one selected diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f0288eae09d1..c15b1604a78d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2273,6 +2273,7 @@ finish_call_expr (tree fn, vec **args, bool disallow_virtual, related to CWG issues 515 and 1005. */ || (TREE_CODE (fn) != COMPONENT_REF && non_static_member_function_p (fn) + && !DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (get_first_fn (fn)) && current_class_ref && type_dependent_expression_p (current_class_ref))) { @@ -2351,8 +2352,16 @@ finish_call_expr (tree fn, vec **args, bool disallow_virtual, [class.access.base] says that we need to convert 'this' to B* as part of the access, so we pass 'B' to maybe_dummy_object. */ - object = maybe_dummy_object (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn)), - NULL); + if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (get_first_fn (fn))) + { + /* A constructor call always uses a dummy object. (This constructor + call which has the form A::A () is actually invalid and we are + going to reject it later in build_new_method_call.) */ + object = build_dummy_object (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn))); + } + else + object = maybe_dummy_object (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn)), + NULL); if (processing_template_decl) { -- 2.47.2