public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-3537] c++: correct object scope handling
Date: Wed, 15 Sep 2021 04:05:45 +0000 (GMT)	[thread overview]
Message-ID: <20210915040545.A37D53857802@sourceware.org> (raw)

https://gcc.gnu.org/g:ba9b07d0259b38a9eccd4eb0df327d3aaabad3c6

commit r12-3537-gba9b07d0259b38a9eccd4eb0df327d3aaabad3c6
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Sep 13 16:10:09 2021 -0400

    c++: correct object scope handling
    
    The way cp_parser_lookup_name handles object scope (i.e. the scope on the
    RHS of a . or -> expression) is a bit subtle: before the lookup it's in
    parser->context->object type, and after the lookup it's in
    parser->object_scope.  But a couple of places that elide lookups were
    failing to do the same transform.
    
    I'm not aware of this breaking anything currently.
    
    gcc/cp/ChangeLog:
    
            * parser.c (cp_parser_template_name): Move object type.
            (cp_parser_pre_parsed_nested_name_specifier): Likewise.

Diff:
---
 gcc/cp/parser.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index ab1dc81b997..7a0b6234350 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -18405,6 +18405,7 @@ cp_parser_template_name (cp_parser* parser,
 	    {
 	      /* We're optimizing away the call to cp_parser_lookup_name, but
 		 we still need to do this.  */
+	      parser->object_scope = parser->context->object_type;
 	      parser->context->object_type = NULL_TREE;
 	      return identifier;
 	    }
@@ -33575,7 +33576,8 @@ cp_parser_pre_parsed_nested_name_specifier (cp_parser *parser)
   /* Set the scope from the stored value.  */
   parser->scope = saved_checks_value (check_value);
   parser->qualifying_scope = check_value->qualifying_scope;
-  parser->object_scope = NULL_TREE;
+  parser->object_scope = parser->context->object_type;
+  parser->context->object_type = NULL_TREE;
 }
 
 /* Consume tokens up through a non-nested END token.  Returns TRUE if we


                 reply	other threads:[~2021-09-15  4:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210915040545.A37D53857802@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).