From patchwork Tue Jan 31 13:24:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 50905 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2795109wrn; Tue, 31 Jan 2023 06:57:58 -0800 (PST) X-Google-Smtp-Source: AK7set+H4j8x6WT3dbSHy2wS9q5bJk0UTu9r19FNPUC+xzQsgTXBOlT+SCcbo9+5LUCKcG4brWvv X-Received: by 2002:a17:906:3c4b:b0:879:6abe:915e with SMTP id i11-20020a1709063c4b00b008796abe915emr19137304ejg.69.1675177078269; Tue, 31 Jan 2023 06:57:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675177078; cv=none; d=google.com; s=arc-20160816; b=K0Hv4Wrfb/4v3ZorwerQfiwt0AsHmn6S+ahVE3emNBufa/hsxJHGuNnUB3JblUx9zb aK/SBc+aD/BiI0BTKwYnKCVYa4dme5VrT3lZ0wbmfzPcs+4KVp+AcNoTQmoyWVThRR0S UWWLpLzDAOl4ns7gFPmjOo7KM/IG7fCLpNhZ3uut404znmH81XnWYlm3+44XzwQCdkLe uyG0ZiDn9LeMtSWZOJY94a9MiYB/npeqSutHMUkdtH5yPHRyrhyO+3HttEPujOMsILTf Os4t0D5RYzdFepSDtubyzIiCHl9Z5gyR9c20GIsxINABGfpXRPQd6nsB6+fJnJjR4fMJ CHdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=/8gxoLyrPijav51rF9wNEEiraKIngEtnWCJxqVnOD+8=; b=Sl3+5hB/JxwdHawTceHPsPvGvaH/pqdANt/QgPROlbhMhqzE1tiwbvZItohrC49/vw gw3N2qvih1wyrEuL2KN8pRses46RSHk0Szq5vpqmh7oT+xR8dLgSXfOHpDIgsHI6yoq/ K2wermDQzN/gLfRcVW/nCpz5nMaxDn7MRgQltx+YtcWT0gND5Ci960zGCBEteUKS7yKU dqSJ5GiNRu1UW/ehPRy3Bdviz5vlwmBSztwPGa04ToueUGCvHKgZ+wqc0NbvWnE3n9o7 SyPYhMLIUCwW7KzeOSjZp4AQdYrUimuT3Fv5JL8HVhdaiM1nnJhqyILEdwS6VFVH7uJQ iRoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=JdKJn1aw; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 26-20020a170906011a00b0086f05817f39si22192155eje.39.2023.01.31.06.57.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 06:57:58 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=JdKJn1aw; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 08ECD385CF04 for ; Tue, 31 Jan 2023 13:30:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 09CA73959CBA for ; Tue, 31 Jan 2023 13:28:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 09CA73959CBA Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-ej1-x633.google.com with SMTP id mc11so19086376ejb.10 for ; Tue, 31 Jan 2023 05:28:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/8gxoLyrPijav51rF9wNEEiraKIngEtnWCJxqVnOD+8=; b=JdKJn1aw888iEp0RQrcXmhaXq8zD7HmOAkNYYFiwnAkb3paurWOvxVmo+pAgdM4pw7 /RNOG/puddmqdQdsf+aBNNerw8DRalFW2pfOPoPdZ1OYoChttZdecnVMMsMscGYBqLV2 7SMfuJCRgm1GY2mJLtsizo7SSf79gAVCJbzIXeKoMzirXwihQAoSXhy8M0rtI728JRio /U2DkloUM3VKmItKYY9DoZV/wKvfVU1+6g0NyD+K4WVoM1JyWnVjAit0pzrtPWVHaVE7 PWIsv5Phhl9oyqoB/nDXIfJvuMzp/E2SXhhby9KsRVF6ZBW0H0s8p/6+nqMQ/XldtbmW Q7SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=/8gxoLyrPijav51rF9wNEEiraKIngEtnWCJxqVnOD+8=; b=ucE2IJX3+80j/SN5fx9IbBk/F7zTx44R/vOEgg2aFo9KaUQgEMU+MdOaVmhf+9SpLO pDgpm0tcAYHoQt0cYiCPu+mfYJiiUgad9lWSeKMmWOe492LtODldWaD8kze60AXwJOaa pLKFWGWZI8SZ7WBHMcfu9J8uXOxvz2/9BUORfsynb2lv8drAhCn8PHcbWG7ZGsQgAh7Z 432o84DCtZ9ip0sRaFndVe0UNGGS6VRVvEgd2EammGS4ZhjRUD/gA3Dp87ybXrgHYpGM bgPfi5RQ71CzaNltquauyzRKkxL/tTwV+Faw6aLWi1HU9hpoOYsdygVvrV9ST1VlpHsz gBEQ== X-Gm-Message-State: AO0yUKX67PidulhImIyDD1fgicacLjKK4c4rtjf1DUAzOzzh45HwWIP5 Y8+fGz2Mt9GtkC+Jk69a3ortLRLYVRplH7hjOg== X-Received: by 2002:a1c:4c12:0:b0:3dd:1c45:a90e with SMTP id z18-20020a1c4c12000000b003dd1c45a90emr3199952wmf.25.1675171239592; Tue, 31 Jan 2023 05:20:39 -0800 (PST) Received: from platypus.lan ([2001:861:5e4c:3bb0:6424:328a:1734:3249]) by smtp.gmail.com with ESMTPSA id l11-20020a05600c2ccb00b003cf71b1f66csm18575429wmc.0.2023.01.31.05.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 05:20:39 -0800 (PST) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [COMMITTED] gccrs: rustc_attrs: Allow `rustc_inherit_overflow_checks` as a builtin.. Date: Tue, 31 Jan 2023 14:24:24 +0100 Message-Id: <20230131132424.661382-1-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-15.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756550479804307279?= X-GMAIL-MSGID: =?utf-8?q?1756550479804307279?= ..attribute. We cannot yet handle this attribute, but we should not reject it either gcc/rust/ChangeLog: * util/rust-attributes.cc: Add `rustc_inherit_overflow_checks` to list of builtin attributes. gcc/testsuite/ChangeLog: * rust/compile/rustc_attr1.rs: New test. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/rust/util/rust-attributes.cc | 32 ++++++++++++----------- gcc/testsuite/rust/compile/rustc_attr1.rs | 13 +++++++++ 2 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 gcc/testsuite/rust/compile/rustc_attr1.rs diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc index 2cefdb247d1..9db77b40dfb 100644 --- a/gcc/rust/util/rust-attributes.cc +++ b/gcc/rust/util/rust-attributes.cc @@ -26,21 +26,23 @@ namespace Rust { namespace Analysis { // https://doc.rust-lang.org/stable/nightly-rustc/src/rustc_feature/builtin_attrs.rs.html#248 -static const BuiltinAttrDefinition __definitions[] = { - {"inline", CODE_GENERATION}, - {"cold", CODE_GENERATION}, - {"cfg", EXPANSION}, - {"cfg_attr", EXPANSION}, - {"deprecated", STATIC_ANALYSIS}, - {"allow", STATIC_ANALYSIS}, - {"doc", HIR_LOWERING}, - {"must_use", STATIC_ANALYSIS}, - {"lang", HIR_LOWERING}, - {"link_section", CODE_GENERATION}, - {"no_mangle", CODE_GENERATION}, - {"repr", CODE_GENERATION}, - {"path", EXPANSION}, -}; +static const BuiltinAttrDefinition __definitions[] + = {{"inline", CODE_GENERATION}, + {"cold", CODE_GENERATION}, + {"cfg", EXPANSION}, + {"cfg_attr", EXPANSION}, + {"deprecated", STATIC_ANALYSIS}, + {"allow", STATIC_ANALYSIS}, + {"doc", HIR_LOWERING}, + {"must_use", STATIC_ANALYSIS}, + {"lang", HIR_LOWERING}, + {"link_section", CODE_GENERATION}, + {"no_mangle", CODE_GENERATION}, + {"repr", CODE_GENERATION}, + {"path", EXPANSION}, + // From now on, these are reserved by the compiler and gated through + // #![feature(rustc_attrs)] + {"rustc_inherit_overflow_checks", CODE_GENERATION}}; BuiltinAttributeMappings * BuiltinAttributeMappings::get () diff --git a/gcc/testsuite/rust/compile/rustc_attr1.rs b/gcc/testsuite/rust/compile/rustc_attr1.rs new file mode 100644 index 00000000000..4bc7d5e3553 --- /dev/null +++ b/gcc/testsuite/rust/compile/rustc_attr1.rs @@ -0,0 +1,13 @@ +// { dg-additional-options "-w" } + +#![feature(rustc_attrs)] + +pub struct NotI8(i8); + +impl NotI8 { + #[inline] + #[rustc_inherit_overflow_checks] + pub fn add(self, other: NotI8) -> NotI8 { + NotI8(self.0 + other.0) + } +}