PR c++/84447 - ICE with deleted inherited ctor with default arg.
authorJason Merrill <jason@redhat.com>
Mon, 26 Feb 2018 17:06:07 +0000 (12:06 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 26 Feb 2018 17:06:07 +0000 (12:06 -0500)
* call.c (build_over_call): Handle deleted functions in one place.

From-SVN: r258003

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp0x/inh-ctor31.C [new file with mode: 0644]

index 97559ede22335fef0c87be1a0aa5671e0793f68d..59d4ceead6713eff18418fbdc92df60c5358030c 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-26  Jason Merrill  <jason@redhat.com>
+
+       PR c++/84447 - ICE with deleted inherited ctor with default arg.
+       * call.c (build_over_call): Handle deleted functions in one place.
+
 2018-02-26  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/84533
index 7c93c6d8290a4d84e388aa6ca22a15e8273370d3..c47befdbf7f88340290837ec352d47394868b2fa 100644 (file)
@@ -7665,8 +7665,12 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
     deduce_inheriting_ctor (fn);
 
   /* Make =delete work with SFINAE.  */
-  if (DECL_DELETED_FN (fn) && !(complain & tf_error))
-    return error_mark_node;
+  if (DECL_DELETED_FN (fn))
+    {
+      if (complain & tf_error)
+       mark_used (fn);
+      return error_mark_node;
+    }
 
   if (DECL_FUNCTION_MEMBER_P (fn))
     {
@@ -7710,12 +7714,6 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
      conversions.  */
   if (flags & LOOKUP_SPECULATIVE)
     {
-      if (DECL_DELETED_FN (fn))
-       {
-         if (complain & tf_error)
-           mark_used (fn);
-         return error_mark_node;
-       }
       if (cand->viable == 1)
        return fn;
       else if (!(complain & tf_error))
@@ -8090,7 +8088,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
 
       /* [class.copy]: the copy constructor is implicitly defined even if
         the implementation elided its use.  */
-      if (!trivial || DECL_DELETED_FN (fn))
+      if (!trivial)
        {
          if (!mark_used (fn, complain) && !(complain & tf_error))
            return error_mark_node;
@@ -8121,8 +8119,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
     }
   else if (DECL_ASSIGNMENT_OPERATOR_P (fn)
           && DECL_OVERLOADED_OPERATOR_IS (fn, NOP_EXPR)
-          && trivial_fn_p (fn)
-          && !DECL_DELETED_FN (fn))
+          && trivial_fn_p (fn))
     {
       tree to = cp_stabilize_reference
        (cp_build_fold_indirect_ref (argarray[0]));
@@ -8166,8 +8163,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
 
       return val;
     }
-  else if (!DECL_DELETED_FN (fn)
-          && trivial_fn_p (fn))
+  else if (trivial_fn_p (fn))
     {
       if (DECL_DESTRUCTOR_P (fn))
        return fold_convert (void_type_node, argarray[0]);
diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor31.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor31.C
new file mode 100644 (file)
index 0000000..071f178
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/84447
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  template<typename T> A(T, T = 0) = delete;
+};
+
+struct B : A
+{
+  using A::A;                  // { dg-error "deleted" }
+};
+
+B b(0);                                // { dg-error "deleted" }