From patchwork Fri Apr 15 01:00:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1617519 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=VoQg7AYd; 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KfdLj2YDHz9s07 for ; Fri, 15 Apr 2022 11:01:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5DAC43857018 for ; Fri, 15 Apr 2022 01:01:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5DAC43857018 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1649984472; bh=8A2cs6spKkMsA8ZBlhwoqGxFw82B2ZQqQ7tz5MkNcRU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VoQg7AYdUb/Arn2kB79g308aadmrVq/GU7kh5YnARLlsfxO+Ri5MadIumY+nod9+z 48Lv4wEuFna+/5zID86BPvAAsNF/cdbH0sGOMDaNGD7dePQWajD955jYPdSBmisNaG J0yfoaXok4FW8cUHoAowCO3ztDlUU1lTLYkEyT8k= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 8D2A73857374 for ; Fri, 15 Apr 2022 01:00:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8D2A73857374 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607-u7f4erllMxm06WZ1xlvvXA-1; Thu, 14 Apr 2022 21:00:28 -0400 X-MC-Unique: u7f4erllMxm06WZ1xlvvXA-1 Received: by mail-qk1-f200.google.com with SMTP id v14-20020a05620a0f0e00b00699f4ea852cso4563503qkl.9 for ; Thu, 14 Apr 2022 18:00:28 -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=8A2cs6spKkMsA8ZBlhwoqGxFw82B2ZQqQ7tz5MkNcRU=; b=ZpRoqJAWscxKFmAIVZZLeCozdeyVik4okmCp0URb+9SaB545/070cKd+4M9rKvgk8+ AVnhxUp6Ox4xsiXJ8BRJy4/LID10r48eE4bbTKBotXQfa5u8R0NfF1Mgu3LiVLSEFIU1 V8J8QtqqDIq0j14z3mK86UtyWo+P7TKtamG4FGsDnyFVdRbC5eubUyYH41zZFbtSJW01 s6yxFMucZit/i1Z3c3Aw7WCeD5oMmCpsvK0ywHFpJQh211vjbigve4HaX+GitFIweN1i re3l4A0TcxrKSozqOW0dTgiB9le4gqH8vTxgRKIqn5Yt+Kb9dhtM9kiddbknmTU0YFBj WwQA== X-Gm-Message-State: AOAM530J240fQ5TJv5PlzxmwlCQTNEoXx7HXNrkKroFuhWYS2P/m1HDh 1byCxBq6278Bl44oXVmkct+uulerXXi7tyoWWV/c98W6DhQbvZ6G1bC2i6szbKEQOlgppZw8YEH vUhkTLmUmnrVr/m2L+lMDQPMOvWhNLTd7a45dDiasm4E8Ltk3m3vK7hDFCKAWUSuaHQ== X-Received: by 2002:a05:620a:4092:b0:69c:5b0a:a127 with SMTP id f18-20020a05620a409200b0069c5b0aa127mr4031384qko.375.1649984427670; Thu, 14 Apr 2022 18:00:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0zoGr9wn9r/S+RaSgKDjmqYMa1bZV+341IbKOOck6cohPsMHmQ4HCEaQqTRYjYdHMmyo7JQ== X-Received: by 2002:a05:620a:4092:b0:69c:5b0a:a127 with SMTP id f18-20020a05620a409200b0069c5b0aa127mr4031365qko.375.1649984427260; Thu, 14 Apr 2022 18:00:27 -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 w14-20020ac857ce000000b002f1ccd62225sm2226346qta.79.2022.04.14.18.00.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 18:00:26 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: using in diagnostics [PR102987] Date: Thu, 14 Apr 2022 21:00:23 -0400 Message-Id: <20220415010023.3512094-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.1 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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 expression pretty-printing code crashed on a location wrapper with no type, and didn't know what to do with a USING_DECL. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/102987 gcc/cp/ChangeLog: * error.cc (dump_expr): Handle USING_DECL. [VIEW_CONVERT_EXPR]: Just look through location wrapper. gcc/testsuite/ChangeLog: * g++.dg/diagnostic/using1.C: New test. --- gcc/cp/error.cc | 8 ++++++++ gcc/testsuite/g++.dg/diagnostic/using1.C | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/g++.dg/diagnostic/using1.C base-commit: 031bd52e482a53314d3dfac2d375c1033a6b7031 diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index e76842e1a2a..1e944ca3f75 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -2203,6 +2203,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) case WILDCARD_DECL: case OVERLOAD: case TYPE_DECL: + case USING_DECL: case IDENTIFIER_NODE: dump_decl (pp, t, ((flags & ~(TFF_DECL_SPECIFIERS|TFF_RETURN_TYPE |TFF_TEMPLATE_HEADER)) @@ -2584,6 +2585,13 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) case VIEW_CONVERT_EXPR: { tree op = TREE_OPERAND (t, 0); + + if (location_wrapper_p (t)) + { + dump_expr (pp, op, flags); + break; + } + tree ttype = TREE_TYPE (t); tree optype = TREE_TYPE (op); diff --git a/gcc/testsuite/g++.dg/diagnostic/using1.C b/gcc/testsuite/g++.dg/diagnostic/using1.C new file mode 100644 index 00000000000..eb4f18d1d8b --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/using1.C @@ -0,0 +1,16 @@ +// PR c++/102987 +// { dg-do compile { target c++11 } } + +struct a { + bool b(); +}; +template struct d : c { + using c::e; + using f = d; + constexpr int g(decltype(e.b())) { return buh; } // { dg-error "buh" } +}; +struct h { + a e; +}; +using i = d; +auto j = i{}.g(1);