From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 5792A385782B for ; Tue, 30 Jan 2024 12:11:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5792A385782B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5792A385782B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::431 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616710; cv=none; b=T2SPG6tS/mvuQ8yX/WkG9tPZZgfDNi7qwJ+v9Dub1paW1pQfIHYVXrxQ1X9F9B5sh+pCNvyxgICtYeb3nS2X4X+EcvPBTiDI7+2YCCc9wG+5QJ+Ef50ij6mYW0eTaKsjILPouhcEbAhmJyjpbbacDywg+QzSYs+6iVG/ShHhCc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616710; c=relaxed/simple; bh=7k7mn6p3lrl2ihACY7vMxG71UCBRpmbrae3GAaT5gH0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=TVYxM4x2Orvp4f3mirT8jVc1IbR7Id9KM6r7lsLpHrfaGeIOzp10co7H8AT4olYOPwBrIiTOMVo9IZeAc4+IbHDq+O2PABsjqnIQGFXtbCtZRBe9Pd30ru/p0V3OQJrgkYcFDWnQ+68eSLw9/hNXCbc2U5ucjV9l4dRYrH+WQt0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3392b12dd21so2802034f8f.0 for ; Tue, 30 Jan 2024 04:11:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1706616684; x=1707221484; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=q9oMAxsEtHW0+XB5LokHl9xydjw6XePdJYl8XMqhRK8=; b=hVdIb35qvIJnx0BxAbaDY9Mwwa9U4sJHe1/H00WBbj+fDPQp3VDe5TC886uXoGVbph GbLX8hRKd7ix5STCnvSYoaEIZq9tfZVAav+l+1hj4XMq54u+mwuCRLhV+yl9HiC6bKTP oUw4kVD+MIKZR+ocHmNvwOCoELwi7lotxqHXn5RAHHcwXNKzJgJn5i9QCLocnnjlgtz5 kmK6ojdLRwoeC7SREx75wRTq2B59cSTRhVIvm2IG5wXr0wTKB34TAT4lKIMYjYPxLiy+ kTBOVjLc2GgMWC4o3eiB5lRXmSKggyPJvvtTS9kZejf1fVG53YUQyrIm47/oe/frV7ox xXCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706616684; x=1707221484; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=q9oMAxsEtHW0+XB5LokHl9xydjw6XePdJYl8XMqhRK8=; b=ZHHAQtuFFvv4RKHHr68OhegEpWPkjzNYLHpuYFW5okTYQ5BjnXUDY4rr+8HQZsexQw OiXleE4o+jgj+PXgQ+QhtnZNe77Ok20RDezFoqyuYW61bkZJoUN018PvWegpptwuL75A 4LVXUHrNXg3MgCpMY0CJW3JovOKzaLJUe44fXxcsm7NSIRey0Le3CBssYwuYmMvKVlRj w1yx12jV4QvhREH87Vyl4qL2u2KQ81E1HlzecUaVeN71uEL6WFlwC2Ae+p8MmxfG/mor Aaj4XMvRFQCyNXaTW5/VZhBjuEPdg1TmnvQGG7T4D/E5lycKr/6HIfjBLAlsROYJKyax 92OQ== X-Gm-Message-State: AOJu0YwsEUUqMiFvWJyHP1KttfpCTqx6FG6SBZxLGsxHimdsvEEKDoWT P6NE9iArZpI/cnDkfpkW9p/EPFcAiHYs0RsPvm8N5GWoOLHmI+BP5C0zqa+NWHHAAlqmoucz/9b r3g== X-Google-Smtp-Source: AGHT+IELSa0EqUhjwejr8MB6WzX22ajSashhT5PgNXzLwH/JFytab6Zu1jeeOUWQUMSlvjyiO17bsA== X-Received: by 2002:adf:fecc:0:b0:33a:e89f:1dc6 with SMTP id q12-20020adffecc000000b0033ae89f1dc6mr4240599wrs.29.1706616684156; Tue, 30 Jan 2024 04:11:24 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id f9-20020a056000036900b00339307d9d31sm10569894wrf.112.2024.01.30.04.11.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:11:23 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Pierre-Emmanuel Patry Subject: [COMMITTED 045/101] gccrs: Add unsafety member to modules Date: Tue, 30 Jan 2024 13:07:01 +0100 Message-ID: <20240130121026.807464-48-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240130121026.807464-2-arthur.cohen@embecosm.com> References: <20240130121026.807464-2-arthur.cohen@embecosm.com> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.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,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 List-Id: From: Pierre-Emmanuel Patry The rust syntax allows unsafe module even if those are rejected at a later stage. gcc/rust/ChangeLog: * ast/rust-item.h: Add safety status to Modules in the AST. * parse/rust-parse-impl.h (Parser::parse_module): Adapt constructors. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/ast/rust-item.h | 13 ++++++++----- gcc/rust/parse/rust-parse-impl.h | 8 +++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 3480d126bc0..6c3715e1eeb 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -736,6 +736,7 @@ private: Identifier module_name; location_t locus; ModuleKind kind; + Unsafety safety; // Name of the file including the module std::string outer_filename; @@ -766,11 +767,12 @@ public: // Unloaded module constructor Module (Identifier module_name, Visibility visibility, - std::vector outer_attrs, location_t locus, + std::vector outer_attrs, location_t locus, Unsafety safety, std::string outer_filename, std::vector module_scope) : VisItem (std::move (visibility), std::move (outer_attrs)), module_name (module_name), locus (locus), kind (ModuleKind::UNLOADED), - outer_filename (outer_filename), inner_attrs (std::vector ()), + safety (safety), outer_filename (outer_filename), + inner_attrs (std::vector ()), items (std::vector> ()), module_scope (std::move (module_scope)) {} @@ -779,18 +781,19 @@ public: Module (Identifier name, location_t locus, std::vector> items, Visibility visibility = Visibility::create_error (), + Unsafety safety = Unsafety::Normal, std::vector inner_attrs = std::vector (), std::vector outer_attrs = std::vector ()) : VisItem (std::move (visibility), std::move (outer_attrs)), module_name (name), locus (locus), kind (ModuleKind::LOADED), - outer_filename (std::string ()), inner_attrs (std::move (inner_attrs)), - items (std::move (items)) + safety (safety), outer_filename (std::string ()), + inner_attrs (std::move (inner_attrs)), items (std::move (items)) {} // Copy constructor with vector clone Module (Module const &other) : VisItem (other), module_name (other.module_name), locus (other.locus), - kind (other.kind), inner_attrs (other.inner_attrs), + kind (other.kind), safety (other.safety), inner_attrs (other.inner_attrs), module_scope (other.module_scope) { // We need to check whether we are copying a loaded module or an unloaded diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 53b3839db37..2e24a66123b 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -22,6 +22,7 @@ /* DO NOT INCLUDE ANYWHERE - this is automatically included with rust-parse.h * This is also the reason why there are no include guards. */ +#include "rust-common.h" #include "rust-item.h" #include "rust-token.h" #define INCLUDE_ALGORITHM @@ -2446,8 +2447,8 @@ Parser::parse_module (AST::Visibility vis, // Construct an external module return std::unique_ptr ( new AST::Module (std::move (name), std::move (vis), - std::move (outer_attrs), locus, lexer.get_filename (), - inline_module_stack)); + std::move (outer_attrs), locus, Unsafety::Normal, + lexer.get_filename (), inline_module_stack)); case LEFT_CURLY: { lexer.skip_token (); @@ -2503,7 +2504,8 @@ Parser::parse_module (AST::Visibility vis, return std::unique_ptr ( new AST::Module (std::move (name), locus, std::move (items), - std::move (vis), std::move (inner_attrs), + std::move (vis), Unsafety::Normal, + std::move (inner_attrs), std::move (outer_attrs))); // module name? } default: -- 2.42.1