On Sun, Jun 16, 2024 at 12:18:10PM +1000, Nathaniel Shead wrote:
> No functional change intended; OK for trunk?
> 

In retrospect, committing as obvious after bootstrap+regtest.

> -- >8 --
> 
> I noticed there already exists a getter to get the scope of a lambda
> from its type directly rather than needing to go via
> CLASSTYPE_LAMBDA_EXPR, we may as well use it.
> 
> gcc/cp/ChangeLog:
> 
>       * module.cc (trees_out::get_merge_kind): Use
>       LAMBDA_TYPE_EXTRA_SCOPE instead of LAMBDA_EXPR_EXTRA_SCOPE.
>       (trees_out::key_mergeable): Likewise.
> 
> Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>
> ---
>  gcc/cp/module.cc | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
> index ea7ad0c1f29..6d6044af199 100644
> --- a/gcc/cp/module.cc
> +++ b/gcc/cp/module.cc
> @@ -10686,9 +10686,7 @@ trees_out::get_merge_kind (tree decl, depset *dep)
>              g++.dg/modules/lambda-6_a.C.  */
>           if (DECL_IMPLICIT_TYPEDEF_P (STRIP_TEMPLATE (decl))
>               && LAMBDA_TYPE_P (TREE_TYPE (decl)))
> -           if (tree scope
> -               = LAMBDA_EXPR_EXTRA_SCOPE (CLASSTYPE_LAMBDA_EXPR
> -                                          (TREE_TYPE (decl))))
> +           if (tree scope = LAMBDA_TYPE_EXTRA_SCOPE (TREE_TYPE (decl)))
>               {
>                 /* Lambdas attached to fields are keyed to its class.  */
>                 if (TREE_CODE (scope) == FIELD_DECL)
> @@ -10993,8 +10991,7 @@ trees_out::key_mergeable (int tag, merge_kind mk, 
> tree decl, tree inner,
>       case MK_keyed:
>         {
>           gcc_checking_assert (LAMBDA_TYPE_P (TREE_TYPE (inner)));
> -         tree scope = LAMBDA_EXPR_EXTRA_SCOPE (CLASSTYPE_LAMBDA_EXPR
> -                                               (TREE_TYPE (inner)));
> +         tree scope = LAMBDA_TYPE_EXTRA_SCOPE (TREE_TYPE (inner));
>           gcc_checking_assert (TREE_CODE (scope) == VAR_DECL
>                                || TREE_CODE (scope) == FIELD_DECL
>                                || TREE_CODE (scope) == PARM_DECL
> -- 
> 2.43.2
> 

Reply via email to