diff options
author | ppalka <ppalka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-02-19 17:04:29 +0000 |
---|---|---|
committer | ppalka <ppalka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-02-19 17:04:29 +0000 |
commit | e4e70a578358dd694303f1bb20efe9b15fb5fa81 (patch) | |
tree | 937eb3520803ea011aaae09888625a3c3605e742 | |
parent | 743d9602b2607f78d71022e989e65258f13d60c7 (diff) | |
download | gcc-e4e70a578358dd694303f1bb20efe9b15fb5fa81.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233563 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/pt.c | 10 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 13 |
3 files changed, 21 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dbc674113f8..8f9b0be1327 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2016-02-19 Patrick Palka <ppalka@gcc.gnu.org> + + 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 <jakub@redhat.com> PR c++/69850 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a55dc10fdfc..730838922c7 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 f0288eae09d..c15b1604a78 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2273,6 +2273,7 @@ finish_call_expr (tree fn, vec<tree, va_gc> **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<tree, va_gc> **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) { |