From patchwork Tue Apr 14 15:46:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1270467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.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=bHBUScKi; dkim-atps=neutral Received: from sourceware.org (server2.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 491qbN0kBGz9sSm for ; Wed, 15 Apr 2020 01:46:22 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D1751385DC0D; Tue, 14 Apr 2020 15:46:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1751385DC0D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586879178; bh=vCXUk0SSxoZdF99T511EKXQJIvXwmmozNdu56iMJa7k=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=bHBUScKiYlE1lZZj/L34jmE46FcmRo5BbeI0cQiOi44SqaCdW1AVKHVprn1E9SfJH M8Uz/1e6ppPKMNe2r8uRlBVIDqDDpDyuNvplVSjOoys2eqwZ/2NN5ps5r9FCouf5jt Du1jnzBjk5eDKRqWHb8lUfitovW6gPm+RRx9Sasc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id DC28F385DC06 for ; Tue, 14 Apr 2020 15:46:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DC28F385DC06 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-290-8frNrCi0M4uSKwfol0JVRw-1; Tue, 14 Apr 2020 11:46:13 -0400 X-MC-Unique: 8frNrCi0M4uSKwfol0JVRw-1 Received: by mail-qk1-f197.google.com with SMTP id a67so12129832qke.0 for ; Tue, 14 Apr 2020 08:46:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3il+67os6f0v1FZj3h/BCxYH5lVL2cJ/1SSbWMVKjFM=; b=bQwAQtz50Z3pjBPEKiec0JbGSoyty1YUYQuy0f3zhancRQnprSifU8YRnHP/K3MkVH cOHQU9UmsONGs7vIaGwosT+WPcrbt8B7384+kOzuLL8TWxzQdMoYhJyvpqohvOFbsWRb 04npMkigOeZNpeBXulu3ZmzfJHs+aPGOup6GY6TQUOgE2fpDepcslw2uv4x4KkcpD33r SCl1j7BmjjRJwbp3KiiPuRYjnQtlSOhYvVYUD6lvTCK/m/BP6Vgt6D5tfEP3WPcpEHGn W4qGxSi8dJbBh4cFtwAZSLrcUk3PLsT6Bkm1lR/Uh6hvYosGvJ5iYYpz0GkbKFOZdDzI J+ZA== X-Gm-Message-State: AGi0PuYSUH92caWIkqeswxJX3LMhWc11ySnovilaApeDXIgZyG2E/YH9 1ltmhaWzqzkXS3pNXVU9+UBGomUFLupFhXrHA2OjwOdCX+DCdAfGYoNXCuR3GXBXkuJNeOTIMrX ih+hl9I7nRaKAAicTsg== X-Received: by 2002:aed:3346:: with SMTP id u64mr6692739qtd.1.1586879172044; Tue, 14 Apr 2020 08:46:12 -0700 (PDT) X-Google-Smtp-Source: APiQypI03OXeTtdbairRjp4KIc9LEN51K4u+37a5LiVjNxQvDwiTL9x+6vSB+CR+toX1VWzpcwdwCQ== X-Received: by 2002:aed:3346:: with SMTP id u64mr6692714qtd.1.1586879171752; Tue, 14 Apr 2020 08:46:11 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id y52sm1227120qth.38.2020.04.14.08.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 08:46:10 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: "'decltype_type' not supported" in diagnostic [PR85278] Date: Tue, 14 Apr 2020 11:46:00 -0400 Message-Id: <20200414154600.1280925-1-ppalka@redhat.com> X-Mailer: git-send-email 2.26.0.106.g9fadedd637 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-28.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This fixes a garbled concepts diagnostic by moving the handling of DECLTYPE_TYPE from pp_cxx_type_specifier_seq to cxx_pretty_printer::simple_type_specifier, a move which also seems to be more consistent with the language grammar. This patch also fixes pretty printing of rvalue reference types via cxx_pretty_printer::type_id, which eventually calls pp_c_pointer which currently doesn't distinguish between lvalue and rvalue references. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK to commit? gcc/c-family/ChangeLog: PR c++/85278 * c-pretty-print.c (pp_c_pointer) : Print a double ampersand if it's an rvalue reference type. gcc/cp/ChangeLog: PR c++/85278 * cxx-pretty-print.c (cxx_pretty_printer:simple_type_specifier) : Handle DECLTYPE_TYPE here instead of ... (pp_cxx_type_specifier_seq) : ... here. (cxx_pretty_printer::direct_abstract_declarator) : New no-op case. gcc/testsuite/ChangeLog: PR c++/85278 * g++.dg/concepts/diagnostic9.C: New test. --- gcc/c-family/c-pretty-print.c | 6 +++++- gcc/cp/cxx-pretty-print.c | 17 ++++++++++------- gcc/testsuite/g++.dg/concepts/diagnostic9.C | 11 +++++++++++ 3 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/concepts/diagnostic9.C diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index eccb63096fd..32f30f2d452 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -278,7 +278,11 @@ pp_c_pointer (c_pretty_printer *pp, tree t) if (TREE_CODE (t) == POINTER_TYPE) pp_c_star (pp); else - pp_c_ampersand (pp); + { + pp_c_ampersand (pp); + if (TYPE_REF_IS_RVALUE (t)) + pp_c_ampersand (pp); + } pp_c_type_qualifier_list (pp, t); break; diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index 840b5a8db8b..a26291eee0f 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -1325,6 +1325,7 @@ cxx_pretty_printer::declaration_specifiers (tree t) /* simple-type-specifier: ::(opt) nested-name-specifier(opt) type-name ::(opt) nested-name-specifier(opt) template(opt) template-id + decltype-specifier char wchar_t bool @@ -1363,6 +1364,13 @@ cxx_pretty_printer::simple_type_specifier (tree t) pp_cxx_unqualified_id (this, TYPENAME_TYPE_FULLNAME (t)); break; + case DECLTYPE_TYPE: + pp_cxx_ws_string (this, "decltype"); + pp_cxx_left_paren (this); + this->expression (DECLTYPE_TYPE_EXPR (t)); + pp_cxx_right_paren (this); + break; + default: c_pretty_printer::simple_type_specifier (t); break; @@ -1389,6 +1397,7 @@ pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t) case TEMPLATE_TEMPLATE_PARM: case TYPE_DECL: case BOUND_TEMPLATE_TEMPLATE_PARM: + case DECLTYPE_TYPE: pp_cxx_cv_qualifier_seq (pp, t); pp->simple_type_specifier (t); break; @@ -1399,13 +1408,6 @@ pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t) pp_cxx_nested_name_specifier (pp, TYPE_METHOD_BASETYPE (t)); break; - case DECLTYPE_TYPE: - pp_cxx_ws_string (pp, "decltype"); - pp_cxx_left_paren (pp); - pp->expression (DECLTYPE_TYPE_EXPR (t)); - pp_cxx_right_paren (pp); - break; - case RECORD_TYPE: if (TYPE_PTRMEMFUNC_P (t)) { @@ -1799,6 +1801,7 @@ cxx_pretty_printer::direct_abstract_declarator (tree t) case TEMPLATE_TEMPLATE_PARM: case BOUND_TEMPLATE_TEMPLATE_PARM: case UNBOUND_CLASS_TEMPLATE: + case DECLTYPE_TYPE: break; default: diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic9.C b/gcc/testsuite/g++.dg/concepts/diagnostic9.C new file mode 100644 index 00000000000..b8f1fadd5e0 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/diagnostic9.C @@ -0,0 +1,11 @@ +// PR c++/85278 +// { dg-do compile { target concepts } } + +template +void f2(T a) + requires requires (const decltype(a) &&x) { -x; } +{ } + +int main() { + f2(nullptr); // { dg-error "use of function .*const decltype\\(f2::a\\) *&&" } +}