From patchwork Fri Apr 29 13:21:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1624262 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=V6bNSZh1; 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 4KqY8M1VlWz9sBF for ; Fri, 29 Apr 2022 23:23:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6DFF13949F28 for ; Fri, 29 Apr 2022 13:23:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DFF13949F28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1651238592; bh=yZ3F8CheP70IXTZjipYuYMuuib2f9JtQTUb0Q9pgKy0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=V6bNSZh1RWm6JAiZG/LcvwjkPGhUqkD7jNdPlCxlF2HElONeaZ9JRNDqul9POhTC4 oQvjEyf8iztTvWqEjNf78ibzD7Iyb+6r6KPBKWmTO6SQVxuc5vHsr1nd5q3JubPJE4 QahUDBsGqSw5DgsmHlM6BR8yhDuLgLxLLxybSk8w= 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 E19483949F17 for ; Fri, 29 Apr 2022 13:21:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E19483949F17 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-408-Fn7gzF5VONGoWkIJi2Ay5Q-1; Fri, 29 Apr 2022 09:21:44 -0400 X-MC-Unique: Fn7gzF5VONGoWkIJi2Ay5Q-1 Received: by mail-qv1-f69.google.com with SMTP id u7-20020a0cb407000000b00446687f0b1bso5959399qve.5 for ; Fri, 29 Apr 2022 06:21:44 -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=yZ3F8CheP70IXTZjipYuYMuuib2f9JtQTUb0Q9pgKy0=; b=cYIeJf/6xS5VLQ5oxxu40xBOFSTxthgegCowMSg6l3RixKrC2ERROVZfu/q8ouSV3x jDBFIxkd7yZqZZVMa7/B7/qB4KhJiEG71cIDb54DnyvYMxK6+GXUUmrE1X3f4rIdjhHK wqcIhRiLOhio+/HG8ciBFFE1jtn7PH67poom4BC2dN/xunOtpPzNE9v7osRwPhC0KmhV cL97gCE7ZN+I/3RGDh2OaLJU94Gz5GaXw7Jfn6lfOaPunlmmE1KZWGtBW5w1y9lTGNnF pu7B4zpB8DZ7NFLXHmh93FeJ4yn66bzHVceuU4yOflx2rMKfg+2/VZrUzLKnVs0RB/KP 080g== X-Gm-Message-State: AOAM530++UAirEXPThNEIgiSpIl9BuyFTykYiEzjCSwfH9Nyfm2SswAa AkSudCWQRTyeVn+lPi9MDf4hahUtN+6pdVl/MhCcK9aEo6kBpNAvfB560VNviFqHPsZoaVqs8oA WLtpdQdBtGch3mcmGyl6lJmeQ1D8v7mphI/VcUQkgonvACJdx0NQ3nUB/KOMU9CjxNg== X-Received: by 2002:ac8:5dca:0:b0:2f1:fcc6:d85a with SMTP id e10-20020ac85dca000000b002f1fcc6d85amr27348245qtx.72.1651238503633; Fri, 29 Apr 2022 06:21:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9bP0sXREupsyumocckpZ+weqMn9HT5h2HRZFJa5k+ESNqp7u+OT2IF0JIh9229YAHJUHGOA== X-Received: by 2002:ac8:5dca:0:b0:2f1:fcc6:d85a with SMTP id e10-20020ac85dca000000b002f1fcc6d85amr27348215qtx.72.1651238503211; Fri, 29 Apr 2022 06:21:43 -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 e13-20020a05620a12cd00b0069e908ab48dsm1397673qkl.106.2022.04.29.06.21.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 06:21:41 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: using in diagnostics [PR102987] Date: Fri, 29 Apr 2022 09:21:40 -0400 Message-Id: <20220429132140.1168266-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" The decl pretty-printing code wasn't looking at the flags parameter, so we were printing 'using' in the middle of an expression. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/102987 gcc/cp/ChangeLog: * error.cc (dump_decl) [USING_DECL]: Respect flags. gcc/testsuite/ChangeLog: * g++.dg/diagnostic/using1.C: Check pretty-printing. --- gcc/cp/error.cc | 18 +++++++++++------- gcc/testsuite/g++.dg/diagnostic/using1.C | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) base-commit: a282da2243103d79262ca04f5e3a3cc7b9b06935 prerequisite-patch-id: 488a80b552cc74278a93c46df93c5dfe1e019e81 diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index 2b07136b5ca..53a9073d99b 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -1439,16 +1439,20 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) case USING_DECL: { - pp_cxx_ws_string (pp, "using"); - tree scope = USING_DECL_SCOPE (t); + if (flags & TFF_DECL_SPECIFIERS) + pp_cxx_ws_string (pp, "using"); bool variadic = false; - if (PACK_EXPANSION_P (scope)) + if (!(flags & TFF_UNQUALIFIED_NAME)) { - scope = PACK_EXPANSION_PATTERN (scope); - variadic = true; + tree scope = USING_DECL_SCOPE (t); + if (PACK_EXPANSION_P (scope)) + { + scope = PACK_EXPANSION_PATTERN (scope); + variadic = true; + } + dump_type (pp, scope, flags); + pp_cxx_colon_colon (pp); } - dump_type (pp, scope, flags); - pp_cxx_colon_colon (pp); dump_decl (pp, DECL_NAME (t), flags); if (variadic) pp_cxx_ws_string (pp, "..."); diff --git a/gcc/testsuite/g++.dg/diagnostic/using1.C b/gcc/testsuite/g++.dg/diagnostic/using1.C index eb4f18d1d8b..4090dd24a60 100644 --- a/gcc/testsuite/g++.dg/diagnostic/using1.C +++ b/gcc/testsuite/g++.dg/diagnostic/using1.C @@ -7,6 +7,7 @@ struct a { template struct d : c { using c::e; using f = d; + // { dg-message "decltype .c::e" "" { target *-*-* } 0 } constexpr int g(decltype(e.b())) { return buh; } // { dg-error "buh" } }; struct h {