From 208a53290430fc17e801c7cc8f0f0289184a2d86 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 21 Nov 2018 23:42:09 +0100 Subject: [PATCH] re PR c++/88122 (g++ ICE: internal compiler error: Segmentation fault) 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 | 5 +++++ gcc/cp/method.c | 8 ++++++-- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp0x/implicit15.C | 11 +++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/implicit15.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9305d530adf..ad061f204c4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2018-11-21 Jakub Jelinek + 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. diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 435ba1d7ed3..936dad42122 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bb61952588a..afd928efb56 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-11-21 Jakub Jelinek + 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 index 00000000000..40fadaf5d39 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit15.C @@ -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" } -- 2.30.2