On Fri, Dec 12, 2025 at 11:05:20PM +0700, Jason Merrill wrote:
> On 12/12/25 10:20 PM, Jakub Jelinek wrote:
> > On Fri, Dec 12, 2025 at 07:07:15AM +0700, Jason Merrill wrote:
> > > > It could be done for non-member_access_p too, I just think it will
> > > > never be non-NULL otherwise.
> > > 
> > > Right, so adding the parm seems unnecessary.
> > 
> > It is still needed.  After Marek's patch it isn't used for the
> > parser->context->object_type temporary override, but it is used in the
> > BASELINK addition code.
> 
> Can that depend on object_type being set when entering the function?

Seems like it can.  reflect/* still passes with this patch.
(MEMBER_ACCESS_P wasn't documented for cp_parser_splice_specifier so
there is no comment to adjust.)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 661f4b0e4f4..9ba66cce1f6 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 '[:'.  */
@@ -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.,
@@ -6248,8 +6250,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 +6422,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