https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80259

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
duplicate_decls is called with the DECL_INITIAL is still being NULL on the
newdecl (and olddecl has it a BLOCK).
#0  duplicate_decls (newdecl=<function_decl 0x7fffefc4a100 foo>,
olddecl=<function_decl 0x7fffefc4a000 foo>, newdecl_is_friend=true)
    at ../../gcc/cp/decl.c:1401
#1  0x0000000000a2420c in pushdecl_maybe_friend_1 (x=<function_decl
0x7fffefc4a100 foo>, is_friend=true) at ../../gcc/cp/name-lookup.c:835
#2  0x0000000000a27940 in pushdecl_maybe_friend (x=<function_decl
0x7fffefc4a100 foo>, is_friend=true) at ../../gcc/cp/name-lookup.c:1352
#3  0x0000000000a2aaff in pushdecl_with_scope_1 (x=<function_decl
0x7fffefc4a100 foo>, level=0x7fffefade000, is_friend=true)
    at ../../gcc/cp/name-lookup.c:2349
#4  0x0000000000a2aba2 in pushdecl_with_scope (x=<function_decl 0x7fffefc4a100
foo>, level=0x7fffefade000, is_friend=true)
    at ../../gcc/cp/name-lookup.c:2363
#5  0x0000000000a30b81 in pushdecl_namespace_level (x=<function_decl
0x7fffefc4a100 foo>, is_friend=true) at ../../gcc/cp/name-lookup.c:3978
#6  0x000000000097cf07 in do_friend (ctype=<tree 0x0>,
declarator=<identifier_node 0x7fffefc498a0 foo>, decl=<function_decl
0x7fffefc4a100 foo>, 
    attrlist=<tree 0x0>, flags=NO_SPECIAL, funcdef_flag=false) at
../../gcc/cp/friend.c:640
#7  0x00000000007c9f6a in grokdeclarator (declarator=0x2ad2a00,
declspecs=0x7fffffffd830, decl_context=FIELD, initialized=1, 
    attrlist=0x7fffffffd770) at ../../gcc/cp/decl.c:12060
#8  0x00000000008b879f in grokfield (declarator=0x2ad2a60,
declspecs=0x7fffffffd830, init=<identifier_node 0x7fffefad72a0 delete>, 
    init_const_expr_p=true, asmspec_tree=<tree 0x0>, attrlist=<tree 0x0>) at
../../gcc/cp/decl2.c:806
And only afterwards grokfield reaches:
889               if (init == ridpointers[(int)RID_DELETE])
890                 {
891                   DECL_DELETED_FN (value) = 1;
892                   DECL_DECLARED_INLINE_P (value) = 1;
893                   DECL_INITIAL (value) = error_mark_node;
894                 }
At this point I think we can't call redeclaration_error_message, because we
don't have the new decl anymore, only the merged (old one).  Perhaps custom
error message here if value is a friend and it has non-NULL (or non-NULL and
non-error_mark_node?) DECL_INITIAL and use there location_t for the new decl
from declarator->id_loc (that would be the foo) or input_location (that would
be the deleted) or something similar?

Reply via email to