On Fri, Dec 12, 2025 at 08:27:01PM +0100, Jakub Jelinek wrote:
> On Fri, Dec 12, 2025 at 11:25:57AM -0500, Marek Polacek wrote:
> > @@ -6120,6 +6119,9 @@ cp_parser_splice_specifier (cp_parser *parser, bool 
> > template_p = false,
> >        return error_mark_node;
> >      }
> >  
> > +  /* Remember if we are accessing a member of some object.  */
> > +  const bool member_access_p = !!parser->context->object_type;
> > +
> >    tree expr;
> >    {
> >      /* Temporarily clear parser->context->object_type.  E.g.,
> 
> I think this isn't even needed, you can then just drop the
> member_access_p && part of
>       /* For member access splice-specialization-specifier, try to wrap
>          non-dependent splice for function template into a BASELINK so
>          that cp_parser_template_id can handle it.  */
>       if (member_access_p
>           && parser->context->object_type
>           && DECL_FUNCTION_TEMPLATE_P (OVL_FIRST (expr))
>           && !dependent_type_p (parser->context->object_type))
> Because object_type is only temporarily overridden, it will be restored
> to what it was at the beginning and so can be just tested here.

You're right.  I've pushed the following:

commit 995a757fec62967f0c4cd931a1ad3e716447bc79
Author: Marek Polacek <[email protected]>
Date:   Fri Dec 12 15:51:12 2025 -0500

    Don't pass member_access_p to cp_parser_splice_specifier

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 661f4b0e4f4..69393d63c35 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -6101,7 +6101,6 @@ cp_parser_next_tokens_can_start_splice_scope_spec_p 
(cp_parser *parser)
 
 static cp_expr
 cp_parser_splice_specifier (cp_parser *parser, bool template_p = false,
-                           bool member_access_p = false,
                            bool *targs_p = nullptr)
 {
   /* Get the location of the '[:'.  */
@@ -6150,8 +6149,7 @@ cp_parser_splice_specifier (cp_parser *parser, bool 
template_p = false,
       /* For member access splice-specialization-specifier, try to wrap
         non-dependent splice for function template into a BASELINK so
         that cp_parser_template_id can handle it.  */
-      if (member_access_p
-         && parser->context->object_type
+      if (parser->context->object_type
          && DECL_FUNCTION_TEMPLATE_P (OVL_FIRST (expr))
          && !dependent_type_p (parser->context->object_type))
        {
@@ -6248,8 +6246,7 @@ cp_parser_splice_expression (cp_parser *parser, bool 
template_p,
   parser->object_scope = NULL_TREE;
   parser->qualifying_scope = NULL_TREE;
 
-  cp_expr expr = cp_parser_splice_specifier (parser, template_p,
-                                            member_access_p, &targs_p);
+  cp_expr expr = cp_parser_splice_specifier (parser, template_p, &targs_p);
 
   /* And don't leave the scopes set, either.  */
   parser->scope = NULL_TREE;
@@ -6421,8 +6418,7 @@ cp_parser_splice_scope_specifier (cp_parser *parser, bool 
typename_p,
                                  bool template_p)
 {
   bool targs_p = false;
-  cp_expr scope = cp_parser_splice_specifier (parser, template_p, false,
-                                             &targs_p);
+  cp_expr scope = cp_parser_splice_specifier (parser, template_p, &targs_p);
   const location_t loc = scope.get_location ();
   if (TREE_CODE (scope) == TYPE_DECL)
     scope = TREE_TYPE (scope);

Reply via email to