]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Adjust fix PR c++/68948
authorPatrick Palka <ppalka@gcc.gnu.org>
Fri, 19 Feb 2016 17:04:29 +0000 (17:04 +0000)
committerPatrick Palka <ppalka@gcc.gnu.org>
Fri, 19 Feb 2016 17:04:29 +0000 (17:04 +0000)
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
gcc/cp/pt.c
gcc/cp/semantics.c

index dbc674113f863fb1560b83814eefe32f6b9c12bf..8f9b0be1327ca1d2d4dfecbff5997170a77f1712 100644 (file)
@@ -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
index a55dc10fdfc1e8d1a847c4d4e89efcc6f574cccf..730838922c7c481b2cdfcf81539a83b6f541a074 100644 (file)
@@ -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
index f0288eae09d1c1aeeb77e9588cb4b4c3930b063e..c15b1604a78d0b345558e3bc406740d93d1bb3b1 100644 (file)
@@ -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)
        {