From: Jakub Jelinek Date: Wed, 6 Dec 2017 22:48:39 +0000 (+0100) Subject: re PR c++/80259 (ICE deleting friend function) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=91c95da87e9a4944f145f988ecbc0926bf68e452;p=gcc.git re PR c++/80259 (ICE deleting friend function) PR c++/80259 * decl2.c (grokfield): Diagnose = delete redefinition of a friend. * g++.dg/cpp0x/pr80259.C: New test. From-SVN: r255456 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d8702e3bed9..9bfc72c361d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-12-06 Jakub Jelinek + + PR c++/80259 + * decl2.c (grokfield): Diagnose = delete redefinition of a friend. + 2017-12-06 Jason Merrill * call.c (convert_for_arg_passing): Pass NULL_TREE to diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 13e7b1d180a..2de36fa99bc 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -911,9 +911,18 @@ grokfield (const cp_declarator *declarator, { if (init == ridpointers[(int)RID_DELETE]) { - DECL_DELETED_FN (value) = 1; - DECL_DECLARED_INLINE_P (value) = 1; - DECL_INITIAL (value) = error_mark_node; + if (friendp && decl_defined_p (value)) + { + error ("redefinition of %q#D", value); + inform (DECL_SOURCE_LOCATION (value), + "%q#D previously defined here", value); + } + else + { + DECL_DELETED_FN (value) = 1; + DECL_DECLARED_INLINE_P (value) = 1; + DECL_INITIAL (value) = error_mark_node; + } } else if (init == ridpointers[(int)RID_DEFAULT]) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 176777e9d83..d7196733dd8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-12-06 Jakub Jelinek + + PR c++/80259 + * g++.dg/cpp0x/pr80259.C: New test. + 2017-12-06 David Malcolm PR c/83236 diff --git a/gcc/testsuite/g++.dg/cpp0x/pr80259.C b/gcc/testsuite/g++.dg/cpp0x/pr80259.C new file mode 100644 index 00000000000..9d2a109bcf3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr80259.C @@ -0,0 +1,13 @@ +// PR c++/80259 +// { dg-do compile { target c++11 } } + +void foo () {} // { dg-message "previously defined here" } +void bar (); + +struct A +{ + friend void foo () = delete; // { dg-error "redefinition of" } + friend void bar () = delete; // { dg-message "previously defined here" } +}; + +void bar () {} // { dg-error "redefinition of" }