From patchwork Fri Apr 29 13:21:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1624261 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=W9MN3F+6; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KqY7G4wSWz9sBF for ; Fri, 29 Apr 2022 23:22:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2BA233949F39 for ; Fri, 29 Apr 2022 13:22:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BA233949F39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1651238535; bh=SxaiuVGvauSS2s3I1JtGFgb83cPbvNI4faT/WpUFX7I=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=W9MN3F+6+FD/odq6LiJ604TtJC67PFeIJ3rDQj9T2cvbJz4Jg6ivlWqLfRCSfv2HU 5qvTiRxtNm5Dw18L+HN+HuptVBMeG9yZuM0+AupnaHuprRm2Fzzamut/MwB8vu9QgN aeffWbptWDDsKc4Y1fyOIC8sS3vTXcanm1xnafBA= 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 ESMTPS id 904DB3948825 for ; Fri, 29 Apr 2022 13:21:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 904DB3948825 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-220-vBvt2yaHNwmJgRd_H2vIkA-1; Fri, 29 Apr 2022 09:21:31 -0400 X-MC-Unique: vBvt2yaHNwmJgRd_H2vIkA-1 Received: by mail-qt1-f197.google.com with SMTP id x5-20020a05622a000500b002f37cb8b803so5612685qtw.9 for ; Fri, 29 Apr 2022 06:21:31 -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=SxaiuVGvauSS2s3I1JtGFgb83cPbvNI4faT/WpUFX7I=; b=aDDgnqbqy/HmLf0KH+plDWyrlBFXPUa7wcJbqa+uJyVa/0nANRrMVGZGgh8tkKYpXZ iklRqBl2Z01tg9ltfk7ft1trFgyLw5D9YksnukrIvAgZO4JI0XDcM+NtbpOxpC+wHDGd fA7bFIxuDfSOEDbY6eZtJYbxUcXZ7ScGI4ruph9agR77xaGs/fHqcQumhACrKTTAB5NY Agronyru4mwNub32ZfdMISAgC+lo4LTSmOpFiZ9dJBH5z0EeS+sHLp+T2XlTULQ4GGww lOrl2LtQfhurmHK86zucNzEwmjdeXrc6weUEe2cxGE2bxNJl7knvzOzj3r/nhRUhD7M8 xAcg== X-Gm-Message-State: AOAM5301CSUdbm2IP5oa5oRyz7k6KzMqDIpdIwZsWVUxbQyIkzy/J/7g Loa1mc7l5jPPj6AsIUnor6aWp6B8goqSx9NXzauJnolab1JWcUmWcgNYOU1qQYjsuxBbVHqzRAs 370XI8uD0QcJBN+ZAuUSHyfb798pfPVuvvGaAjeNNFwPFjVqBJ6Kr/7HYdAiROINsxw== X-Received: by 2002:a37:6285:0:b0:69f:9d2a:3258 with SMTP id w127-20020a376285000000b0069f9d2a3258mr6296566qkb.150.1651238490878; Fri, 29 Apr 2022 06:21:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDg1rYIrO1PY9bzZ2O4A/HvgYCHExYHjfeDx9dJ1OiPcLLHoh4k7iZvbZFm/6uTgTTNesMEQ== X-Received: by 2002:a37:6285:0:b0:69f:9d2a:3258 with SMTP id w127-20020a376285000000b0069f9d2a3258mr6296549qkb.150.1651238490460; Fri, 29 Apr 2022 06:21:30 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id w83-20020a376256000000b0069f8a7cf7ffsm1468507qkb.32.2022.04.29.06.21.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 06:21:29 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: dump alias-declaration scope Date: Fri, 29 Apr 2022 09:21:27 -0400 Message-Id: <20220429132127.1167911-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.4 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, 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" An alias can't be declared with a qualified-id in actual code, but in diagnostics we want to know which scope it belongs to, and I think a nested-name-specifier is the best way to provide that. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog: * error.cc (dump_decl): Check TFF_UNQUALIFIED_NAME. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/alias-decl-1.C: Expect qualified name. --- gcc/cp/error.cc | 2 ++ gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) base-commit: a282da2243103d79262ca04f5e3a3cc7b9b06935 diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index 1e944ca3f75..2b07136b5ca 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -1246,6 +1246,8 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) || flags & TFF_CLASS_KEY_OR_ENUM)) { pp_cxx_ws_string (pp, "using"); + if (! (flags & TFF_UNQUALIFIED_NAME)) + dump_scope (pp, CP_DECL_CONTEXT (t), flags); dump_decl (pp, DECL_NAME (t), flags); pp_cxx_whitespace (pp); pp_cxx_ws_string (pp, "="); diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C index 24b05209223..6dcb780e895 100644 --- a/gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C @@ -12,5 +12,5 @@ template struct Ptr {}; // { dg-error "specialization" } struct A { using A = int; // { dg-error "11:ISO C\\+\\+ forbids nested type .A." } -// { dg-error "11:.using A = int. has the same name as" "" { target c++11 } .-1 } +// { dg-error "11:.using A::A = int. has the same name as" "" { target c++11 } .-1 } };