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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org
   Target Milestone|---                         |6.0

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If there is in #c3 extern "C" int abs(int); before the using foo::abs;, it
works fine.
The problem is during do_toplevel_using_decl (and likely other spots in
name-lookup.c) - do_nonmember_using_decl throws away the DECL_ANTICIPATED
olddecls:
2586  /* It is impossible to overload a built-in function; any explicit
2587     declaration eliminates the built-in declaration.  So, if OLDVAL
2588     is a built-in, then we can just pretend it isn't there.  */
2589  if (oldval
2590      && TREE_CODE (oldval) == FUNCTION_DECL
2591      && DECL_ANTICIPATED (oldval)
2592      && !DECL_HIDDEN_FRIEND_P (oldval))
and do_toplevel_using_decl then overwrites the binding->value with an OVERLOAD
that doesn't contain the builtin.
Perhaps we should keep the cxx_binding with ->value of DECL_ANTICIPATED
FUNCTION_DECL around, but hide it with another binding if the new OVERLOAD or
value is not builtin, and then when pushing extern "C" decls look if we don't
have a DECL_ANTICIPATED decl in some earlier binding of the same scope, and if
yes, duplicate_decls that decl with the anticipated one or something similar.

Reply via email to