From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id CCF36385843E for ; Tue, 31 Jan 2023 13:20:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CCF36385843E 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-wm1-x32f.google.com with SMTP id hn2-20020a05600ca38200b003dc5cb96d46so3479578wmb.4 for ; Tue, 31 Jan 2023 05:20:40 -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=T99pWnMwmTz3wcwFgpxNsydbqSG2w6ZqhpUlxXhISNzI5RANYovP61/eGaXkzHnM2X pR1SpgawKLdIojTEx4kpESxod9VoRTEJ5uMusX7kYY0B5NZbm0fRkO8sLnA/ea20FDl6 taNVDVFbe9lWyS3l1A35iAW5thglEiOROpEqrP/CJE/EcYSYv4Ipc74cql8uSAe6Ce21 e9ZvyRfyFdaLHIVNj7/TEv1kAWZTAzaVAnXLVV3RCo+cywD5guMM5BB3ISzy84g28bYU oMVjRNCjU1b7tkNMyW8Z3pBBAGK+TDd2S372K+X+k4cMSbpn11ds8/8RtzDeVNT7VcwT jyKQ== X-Gm-Message-State: AO0yUKWIAgfZThrAWxWKkvYA94U/LB3uwWBK57VEhJYoFMeMtPJPowd+ vZCRK4e8SSJRS2LpS7kxv7+i X-Google-Smtp-Source: AK7set8J6kM2OPsa3yCObdiaA/nf0idf6yVm5ubKmDbR0ml2X0SX6TdRdv/A/cfxGk5ozYzQz0aSgg== 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-15.9 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=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: ..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) + } +} -- 2.39.1