re PR c++/88122 (g++ ICE: internal compiler error: Segmentation fault)
authorJakub Jelinek <jakub@redhat.com>
Wed, 21 Nov 2018 22:42:09 +0000 (23:42 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 21 Nov 2018 22:42:09 +0000 (23:42 +0100)
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.

From-SVN: r266360

gcc/cp/ChangeLog
gcc/cp/method.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/implicit15.C [new file with mode: 0644]

index 9305d530adfd057ced6b65d2f072a8e2e4653271..ad061f204c4d5f015cdac770e04bec372f2caca1 100644 (file)
@@ -1,5 +1,10 @@
 2018-11-21  Jakub Jelinek  <jakub@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.
+
        PR c++/87386
        * parser.c (cp_parser_primary_expression): Use
        id_expression.get_location () instead of id_expr_token->location.
index 435ba1d7ed3ca438e77d34a9d4b74f6e529d0360..936dad42122900c7ff1a6dfd8aecb60b706a90b2 100644 (file)
@@ -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);
index bb61952588a3f21b0e679b0dae79ca11f9fe799a..afd928efb566f7408a783780a3a436484b64d69f 100644 (file)
@@ -1,5 +1,8 @@
 2018-11-21  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/88122
+       * g++.dg/cpp0x/implicit15.C: New test.
+
        PR c++/87386
        * g++.dg/diagnostic/pr87386.C: New test.
        * g++.dg/parse/error17.C: Adjust expected diagnostics.
diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit15.C b/gcc/testsuite/g++.dg/cpp0x/implicit15.C
new file mode 100644 (file)
index 0000000..40fadaf
--- /dev/null
@@ -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" }