From patchwork Fri May 19 18:38:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1783957 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.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=RxuG1eLv; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QNFxN6rxyz20dn for ; Sat, 20 May 2023 04:39:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4752F3858414 for ; Fri, 19 May 2023 18:39:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4752F3858414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684521557; bh=SZGlr9jaEJ5WfxbUzjRatBBX/Wx3ZbNrq5sGbSu/3Pk=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=RxuG1eLvEi23Bv/3+kfu3mWIvY3KnPyfntt230pS2QO3YGqrbWfdxTLYWQcWBVtEI CVqwO6ztxBKt3vTL3tpBPUurEfJtdizp/Od84PPre1lX+MNlN+E6sKZwIjiAliwkpe vadqkQvLBrKYdCXUL/gduVqZlGhp0nXP1/T7wiR8= 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 92D4C3858C41 for ; Fri, 19 May 2023 18:38:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 92D4C3858C41 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-280-4DtJ_-1_PgyZs9jZkEPZtQ-1; Fri, 19 May 2023 14:38:56 -0400 X-MC-Unique: 4DtJ_-1_PgyZs9jZkEPZtQ-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-3f698dea247so8189381cf.0 for ; Fri, 19 May 2023 11:38:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684521535; x=1687113535; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SZGlr9jaEJ5WfxbUzjRatBBX/Wx3ZbNrq5sGbSu/3Pk=; b=Dw0wBMMchQK/8WibG7QMH4g7WLPiJBnj9I/gGKY+FJ2vRMSQCsSX6LfmZUJwzAKwi2 uEeaw418qV45ChDL3l9Uegz0ggclwaWmV4VcGTUoYlkBMpl/+WYzAIkWSRHnQgWWaSsK sJC0qjjp47gGIkRQsXgnvci5VeyZtFYJr9TGIIRLZew4tis+f7TfSbJrCCc52XHeSJmp Pqcx2d2/teD77f3s1Uxwa60eMHXnIsdxNGMxKhU8nrr5VCi0yXMPllat4mnRUzCrYL2m 3nPSf8DIlJNWBqXo0HsBrv9RfezAa/sTE5+C21r1HdLwMdQrYVVA3CcQ59QbkMfJqniX ijWA== X-Gm-Message-State: AC+VfDxOR/Agxho9JUxhH90kla15PAB2wpxOEfgv8qSB1Zb36rGWmoH9 KNy6rqMnwQYO3n84/Ph9fcs8he82dMo0XWSuJqAbCKM5ypced5LAymsUxGiQ5tBb2yxmrVQgxfw AKh5j4KVY79kbcJnYdirvwteQ7LgIyAGtTbWI8F2NljqkdFKLp+14Q/Kyil1a28nHe6TwLFu9V+ k= X-Received: by 2002:ac8:7c46:0:b0:3f3:8e14:f597 with SMTP id o6-20020ac87c46000000b003f38e14f597mr4495958qtv.65.1684521534875; Fri, 19 May 2023 11:38:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Z/AyYQx8bAEAZs9S9sMVRw8ucq28U7LUH18qvqGOS6JOxR+6ALLdaYXlCFYTmZiSNLSsGGg== X-Received: by 2002:ac8:7c46:0:b0:3f3:8e14:f597 with SMTP id o6-20020ac87c46000000b003f38e14f597mr4495931qtv.65.1684521534571; Fri, 19 May 2023 11:38:54 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id s7-20020ac85ec7000000b003ee4b5a2dd3sm38912qtx.21.2023.05.19.11.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 11:38:53 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, nathan@acm.org, Patrick Palka Subject: [PATCH] c++: mangle noexcept-expr [PR70790] Date: Fri, 19 May 2023 14:38:50 -0400 Message-ID: <20230519183851.760404-1-ppalka@redhat.com> X-Mailer: git-send-email 2.41.0.rc0.4.g004e0f790f MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.7 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_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This implements noexcept-expr mangling (and demangling) as per the Itanium ABI. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? PR c++/70790 gcc/cp/ChangeLog: * mangle.cc (write_expression): Handle NOEXCEPT_EXPR. libiberty/ChangeLog: * cp-demangle.c (cplus_demangle_operators): Add the noexcept operator. * testsuite/demangle-expected: Test noexcept operator demangling. gcc/testsuite/ChangeLog: * g++.dg/abi/mangle78.C: New test. --- gcc/cp/mangle.cc | 5 +++++ gcc/testsuite/g++.dg/abi/mangle78.C | 14 ++++++++++++++ libiberty/cp-demangle.c | 1 + libiberty/testsuite/demangle-expected | 3 +++ 4 files changed, 23 insertions(+) create mode 100644 gcc/testsuite/g++.dg/abi/mangle78.C diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc index 826c5e76c1d..7dab4e62bc9 100644 --- a/gcc/cp/mangle.cc +++ b/gcc/cp/mangle.cc @@ -3402,6 +3402,11 @@ write_expression (tree expr) else write_string ("tr"); } + else if (code == NOEXCEPT_EXPR) + { + write_string ("nx"); + write_expression (TREE_OPERAND (expr, 0)); + } else if (code == CONSTRUCTOR) { bool braced_init = BRACE_ENCLOSED_INITIALIZER_P (expr); diff --git a/gcc/testsuite/g++.dg/abi/mangle78.C b/gcc/testsuite/g++.dg/abi/mangle78.C new file mode 100644 index 00000000000..a3647711604 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle78.C @@ -0,0 +1,14 @@ +// PR c++/70790 +// { dg-do compile { target c++11 } } + +template +struct A { }; + +template +void f(A); + +int main() { + f({}); +} + +// { dg-final { scan-assembler "_Z1fIiEv1AIXnxcvT__EEE" } } diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index f2b36bcad68..341c66db919 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -1947,6 +1947,7 @@ const struct demangle_operator_info cplus_demangle_operators[] = { "ng", NL ("-"), 1 }, { "nt", NL ("!"), 1 }, { "nw", NL ("new"), 3 }, + { "nx", NL ("noexcept"), 1 }, { "oR", NL ("|="), 2 }, { "oo", NL ("||"), 2 }, { "or", NL ("|"), 2 }, diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index d9bc7ed4b1f..7195cc39c19 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -1659,3 +1659,6 @@ auto f()::{lambda(X<$T0>*, X*)#1}::operator()(X*, _ZZN1XIiE1FEvENKUliE_clEi X::F()::{lambda(int)#1}::operator()(int) const + +_Z1fIiEv1AIXnxcvT__EEE +void f(A)