+2017-12-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/80259
+ * decl2.c (grokfield): Diagnose = delete redefinition of a friend.
+
2017-12-06 Jason Merrill <jason@redhat.com>
* call.c (convert_for_arg_passing): Pass NULL_TREE to
{
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])
{
--- /dev/null
+// 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" }