On Fri, Oct 25, 2019 at 12:39:58AM +0200, Jakub Jelinek wrote:
> Hi!
> 
> When looking into the constexpr new issues and adding is_std_construct_at
> function, I've noticed that with --enable-symvers=gnu-versioned-namespace

That is... sneaky.  I guess I/we need to test with
--enable-symvers=gnu-versioned-namespace every now and then.

> all of that fails, because construct_at (but for other things
> forward or move etc.) aren't directly in std namespace, but in inline
> namespace inside of it (std::_8::{construct_at,forward,move,...}).
> 
> The following patch changes the function all of those calls use to look
> through inline namespaces.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> 2019-10-24  Jakub Jelinek  <ja...@redhat.com>
> 
>       * typeck.c (decl_in_std_namespace_p): Return true also for decls
>       in inline namespaces inside of std namespace.
> 
>       * g++.dg/cpp0x/Wpessimizing-move6.C: New test.
> 
> --- gcc/cp/typeck.c.jj        2019-10-23 20:38:00.022871653 +0200
> +++ gcc/cp/typeck.c   2019-10-24 11:36:14.982981481 +0200
> @@ -9395,8 +9395,16 @@ maybe_warn_about_returning_address_of_lo
>  bool
>  decl_in_std_namespace_p (tree decl)
>  {
> -  return (decl != NULL_TREE
> -       && DECL_NAMESPACE_STD_P (decl_namespace_context (decl)));
> +  while (decl)
> +    {
> +      decl = decl_namespace_context (decl);
> +      if (DECL_NAMESPACE_STD_P (decl))
> +     return true;
> +      if (!DECL_NAMESPACE_INLINE_P (decl))
> +     return false;
> +      decl = CP_DECL_CONTEXT (decl);
> +    }
> +  return false;

Probably deserves a comment.

--
Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA

Reply via email to