From patchwork Wed Dec 1 15:16:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 48369 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 41698385C400 for ; Wed, 1 Dec 2021 15:27:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41698385C400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1638372459; bh=/cVCmUSybXYiyCDATk81EZKzcDPb2uVyvAQywJ8wED4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=C0wdS3iFHS1dMuHYA91Vcd9l4YT+Vt/mnIhpswqo8o1rIwyd3vo6hLaxPUUws7uZR xoPcfn6C5fPw62XFRbvoC7lKTTycXszGBVr1OrAbixcsODkmSLW7jN0leya92wbWnF o8bCQboReTv1CWBgUY26q2BEYPVKz5Ei+nQMGE4A= 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 AE69C385800E for ; Wed, 1 Dec 2021 15:16:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AE69C385800E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-474-FlmxoGVmMUCkKmVOiYAQqg-1; Wed, 01 Dec 2021 10:16:50 -0500 X-MC-Unique: FlmxoGVmMUCkKmVOiYAQqg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7399B81CCB5 for ; Wed, 1 Dec 2021 15:16:49 +0000 (UTC) Received: from pdp-11.redhat.com (unknown [10.22.17.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id E02915DAA5; Wed, 1 Dec 2021 15:16:46 +0000 (UTC) To: GCC Patches , Jason Merrill Subject: [PATCH] c++: ICE with unnamed tparm and concept [PR103408] Date: Wed, 1 Dec 2021 10:16:45 -0500 Message-Id: <20211201151645.1497965-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.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: Marek Polacek via Gcc-patches From: Marek Polacek Reply-To: Marek Polacek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Here we crash when issuing the "constraint C has type T, not bool" error, because pp_cxx_parameter_mapping wasn't prepared to see an anonymous template parameter. With this patch we print error: constraint 'auto() [with = 0]' has type '', not 'bool' The "" is what this patch adds. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? PR c++/103408 gcc/cp/ChangeLog: * cxx-pretty-print.c (pp_cxx_parameter_mapping): Print "" rather than crash on an unnamed template parameter. gcc/testsuite/ChangeLog: * g++.dg/cpp23/concepts-err1.C: New test. --- gcc/cp/cxx-pretty-print.c | 4 +++- gcc/testsuite/g++.dg/cpp23/concepts-err1.C | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp23/concepts-err1.C base-commit: 6b8ecbc6d6652d061d7c72c64352d51eca2df6ca diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index 25cabfee39f..3ea357deb80 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -2891,8 +2891,10 @@ pp_cxx_parameter_mapping (cxx_pretty_printer *pp, tree map) if (TYPE_P (parm)) pp->type_id (parm); + else if (tree name = DECL_NAME (TEMPLATE_PARM_DECL (parm))) + pp_cxx_tree_identifier (pp, name); else - pp_cxx_tree_identifier (pp, DECL_NAME (TEMPLATE_PARM_DECL (parm))); + pp->translate_string (""); pp_cxx_whitespace (pp); pp_equal (pp); diff --git a/gcc/testsuite/g++.dg/cpp23/concepts-err1.C b/gcc/testsuite/g++.dg/cpp23/concepts-err1.C new file mode 100644 index 00000000000..e5bdc542bad --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp23/concepts-err1.C @@ -0,0 +1,6 @@ +// PR c++/103408 +// { dg-do compile { target c++23 } } + +template +concept C = auto([]{}); // { dg-error "constraint" } +static_assert(C<0>); // { dg-error "non-constant condition for static assertion" }