From patchwork Wed Sep 15 04:05:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1528204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=xe0223MZ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H8RVd45s4z9sSs for ; Wed, 15 Sep 2021 14:06:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 539CC385781F for ; Wed, 15 Sep 2021 04:06:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 539CC385781F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1631678807; bh=ZRHjo7gvdNZFbCt3EGq0iE402bWXhoQojRwTlEZHI/8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xe0223MZwC3qD8Tgjr2hLT1hbyfHvnqum0bdULLgIalpno7ZN3vnd56UbGhRL5/XK iJTHnG58u+muSf0X4eYaYOOjNGmMzI9uE5+wZ4h9fyNWz9VdAaIYMpRxUUl6dnnG5s uZVm/oyhBBUoviLduIVhAA+Pr7j91cWHQ2CbNvXw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id D82013857C6F for ; Wed, 15 Sep 2021 04:05:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D82013857C6F Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-142-tLjcWhsROBOkr0ibQ42ung-1; Wed, 15 Sep 2021 00:05:20 -0400 X-MC-Unique: tLjcWhsROBOkr0ibQ42ung-1 Received: by mail-qv1-f71.google.com with SMTP id u8-20020a0cee88000000b00363b89e1c50so2114847qvr.16 for ; Tue, 14 Sep 2021 21:05:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZRHjo7gvdNZFbCt3EGq0iE402bWXhoQojRwTlEZHI/8=; b=ni7jdC43ZT/lAcUqMGg6xVyioZiMg82hEQCPaNiIDUL5WRn6c4DPI0ZeFs1hveCcyw PEA4vn/EKgY5NoFiP6TuCEwGh45hUD3GClGDRY3pSfcswkMrmlBLEeS5zMKqjNiNDHce zjXz+QnYQTeGfP+v/9E5bQYwFQR5KCdf4bH/kRgwZ2SLbcW7PIpN6e29PgCSz1vJ/iMJ SEgKyMRU/NAipHVJYKFmmdYihfNHOIyHC3WbAScmTgs3tkVDuYN6TCNMQb/c5z3AlI4F 3zmxNv7jzr5v6/Eoo+PW+TWW4zeDO36w0FaaFOM1tg07hUfCR7son4nKvH4eJYZTBBmg ouaw== X-Gm-Message-State: AOAM531fxtHUsxCSShQJmnlXxfVIbUlh8hY2Pcohp5DxFRGyr0SRwQLU lGC7mkA3Ib+EralY2vM5aseSsGdPfsiiPSxpXC2Mo5XInFUZFlDvh+5VgVZGTPc1qvnL1e6B3+0 d9kT8M4fdb5x+HFrjWhfDAvgjKCCUgzC+Pvox1Pkpd5PKpV5eOGG/eicrUS8yZJxGxQ== X-Received: by 2002:ac8:570f:: with SMTP id 15mr8227761qtw.335.1631678719638; Tue, 14 Sep 2021 21:05:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGomylz/ijlUQqA6/n7K5TKD6CMaVQrGSTiGuLxJggNkQPqX06Lit8wCIJjjdvxJ8eBWUm0g== X-Received: by 2002:ac8:570f:: with SMTP id 15mr8227749qtw.335.1631678719342; Tue, 14 Sep 2021 21:05:19 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s11817.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id v8sm7276207qtk.49.2021.09.14.21.05.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 21:05:18 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: correct object scope handling Date: Wed, 15 Sep 2021 00:05:16 -0400 Message-Id: <20210915040516.957484-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog: * parser.c (cp_parser_template_name): Move object type. (cp_parser_pre_parsed_nested_name_specifier): Likewise. --- gcc/cp/parser.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) base-commit: bd55fa102715c7442c050b193dadfdb5337e2377 prerequisite-patch-id: 6aead84b2823eea91fa3886a64c032aa4882cec3 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