Hi!

On the following testcase we ICE in maybe_explain_implicit_delete, because
FUNCTION_FIRST_USER_PARMTYPE (decl) is NULL - there are no user parameters
and ...
>From what I understood, const_p is used only in certain cases like const vs.
non-const copy constructor or assignment operator, if the sfk has no user
parameters, usually parm_type is just the void_type terminating the argument
list and also not really interesting for const_p computation.
So, this patch just arranges to pass false as const_p in this case.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-11-21  Jakub Jelinek  <ja...@redhat.com>

        PR c++/88122
        * method.c (maybe_explain_implicit_delete): If
        FUNCTION_FIRST_USER_PARMTYPE (decl) is NULL, set const_p to false
        instead of ICEing.

        * g++.dg/cpp0x/implicit15.C: New test.

--- gcc/cp/method.c.jj  2018-11-16 10:22:18.668258171 +0100
+++ gcc/cp/method.c     2018-11-21 15:42:08.441785625 +0100
@@ -1821,8 +1821,12 @@ maybe_explain_implicit_delete (tree decl
       if (!informed)
        {
          tree parms = FUNCTION_FIRST_USER_PARMTYPE (decl);
-         tree parm_type = TREE_VALUE (parms);
-         bool const_p = CP_TYPE_CONST_P (non_reference (parm_type));
+         bool const_p = false;
+         if (parms)
+           {
+             tree parm_type = TREE_VALUE (parms);
+             const_p = CP_TYPE_CONST_P (non_reference (parm_type));
+           }
          tree raises = NULL_TREE;
          bool deleted_p = false;
          tree scope = push_scope (ctype);
--- gcc/testsuite/g++.dg/cpp0x/implicit15.C.jj  2018-11-21 15:59:29.849741499 
+0100
+++ gcc/testsuite/g++.dg/cpp0x/implicit15.C     2018-11-21 15:58:00.912197089 
+0100
@@ -0,0 +1,11 @@
+// PR c++/88122
+// { dg-do compile { target c++11 } }
+
+struct A {
+  A (...);     // { dg-message "candidate" }
+  A ();                // { dg-message "candidate" }
+};
+struct B : A {
+  using A::A;  // { dg-error "is ambiguous" }
+               // { dg-message "is implicitly deleted because the default 
definition would be ill-formed" "" { target *-*-* } .-1 }
+} b{3};                // { dg-error "use of deleted function" }

        Jakub

Reply via email to