From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id CD32B3858408 for ; Thu, 1 Aug 2024 14:58:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD32B3858408 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 CD32B3858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::629 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524342; cv=none; b=iwZ3r3mk+v396lXTy1gQuIsZd5treVULF4PzW1Hv2tgLeZVjrXkHbZdch2ufv2G2J/ej2IDgn2sABnKGHmikreGDkl2DHsZ/Vb5cdF/HiisJaIklKsGBTIzqgDpmqKzGazpQk88cL/Jc7LLkyoWV7I7wFKhF6rtdwtGfc1bvOn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524342; c=relaxed/simple; bh=Rvx7KhahrNAhWW2E9qZBUvR2ViE/TLMocucQJt0JcoE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YcI31ESRKVYFCa+cwo0RBUGQUv0/rpCHveMi9sTRWMMPhZvd39rJa6gUR/srlkGnGAdKToyLigTRP7TToKWPGcqHGs/RS921s3opC/okfggQ2/f4fckRsFF/QirbIBqolKrnaZoFRLV2xtLvxqXNwTquRw89F2GeMjZcMQNlNCg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a7aaa77fac4so298316266b.0 for ; Thu, 01 Aug 2024 07:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1722524331; x=1723129131; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4RmKto9XmBd5Yu5yZG+gvZdX2GWPxXq/gyhktO3MYX8=; b=YRQnQM/JoV1QOoyDqC+9C/71iR1X8lIToU4TbckD3Qiq3n7n5Vbry5ZJItV40WSemf 4bbhM5tErO7N8a41C6aL6amX+ln+o9DL+XUU1kNCMTpryJ2RypzsH4CqUMxVFeOoEijx NAiG5BrQbuc2Y2fcFZ74I2X8jUA1vuLW1M/YY9gxFs+IPkO+3dXz+72WlGxRuO+V35lF HeOmADx0qPtLpzoDYiQYMuiHNwrIMaB1I7C5o4oxNh0VrqIwpKW/JJFqK9SkzIbCG3eE mhQb7ZXRywIH4jin46SSiXKdzBRrS9ESDopNmbXiX/GzTVud4Rj4PS9/AbCCrZ08Gc+3 Hc0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722524331; x=1723129131; h=content-transfer-encoding:mime-version: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=4RmKto9XmBd5Yu5yZG+gvZdX2GWPxXq/gyhktO3MYX8=; b=gdOThYavo+p2rZPQoruDvtzU5XnrWlUq5uzZaIW93w4J1IKtj+G0Uvt90PW/1nvLoQ 7N54yPTUpnErr3VXtPZEF6BxwGw59AvjB8AY+N8k6NCO/B++GYAzH7geC/OcFAUPryO+ c5yddf2drUskzFUu2TSkPZTZJRzZcP/rYV6YnyZMLRKR3qw9spvdJwAE3LZ5fGsy3pIO WFwaL4J8Uq15U2gqAhNYZ1TwRN75frJczXiz30Aw0N65w74dTf8fbywqvo5aKIhjm4le aegeYce0QYHK7UzKrWGlhYPOWe5resfnnU3je/UBODiSodegPjx20Dt9VmD7GjDIEb+s WrSQ== X-Gm-Message-State: AOJu0YwD06Xa3YjmqpFC66kO8A1+06nkFV7XCte/K71DL931p6WuYVIj kGPvxG3VR06MdonS2Xq7YtPdspi4l48w4105cc2UUGfaTQBTpr6erXnx51jFLo/GqmmEc3bRfRu SnKPT X-Google-Smtp-Source: AGHT+IGnx7UvndyXI0x7yXWf1Xmhgd7+2/H9ppK80CiC/KegHixumUy+mlzXuPY5zev/K4wZiyx1tg== X-Received: by 2002:a50:ff0b:0:b0:58b:1a5e:c0e7 with SMTP id 4fb4d7f45d1cf-5b7f56fcbe3mr520510a12.35.1722524331245; Thu, 01 Aug 2024 07:58:51 -0700 (PDT) Received: from platypus.lan ([2a04:cec2:9:dc84:3622:6733:ff49:ee91]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac63590592sm10252456a12.25.2024.08.01.07.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:58:51 -0700 (PDT) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [PATCH 026/125] gccrs: extern-types: Lower to HIR::ExternalTypeItem properly Date: Thu, 1 Aug 2024 16:56:22 +0200 Message-ID: <20240801145809.366388-28-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801145809.366388-2-arthur.cohen@embecosm.com> References: <20240801145809.366388-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.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: gcc/rust/ChangeLog: * hir/rust-ast-lower-extern.h: Lower to HIR::ExternalTypeItem nodes. * hir/tree/rust-hir-item.h (class ExternalTypeItem): Create private visibility by default as extern types have no visibility - add a comment about the correctness of this. --- gcc/rust/hir/rust-ast-lower-extern.h | 9 ++++++++- gcc/rust/hir/tree/rust-hir-item.h | 10 ++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gcc/rust/hir/rust-ast-lower-extern.h b/gcc/rust/hir/rust-ast-lower-extern.h index e495b16632d..f9e067c8e95 100644 --- a/gcc/rust/hir/rust-ast-lower-extern.h +++ b/gcc/rust/hir/rust-ast-lower-extern.h @@ -22,6 +22,7 @@ #include "rust-ast-lower-base.h" #include "rust-ast-lower-type.h" #include "rust-ast-lower.h" +#include "rust-hir-full-decls.h" namespace Rust { namespace HIR { @@ -116,7 +117,13 @@ public: void visit (AST::ExternalTypeItem &type) override { - rust_sorry_at (type.get_locus (), "extern types are not implemented yet"); + auto crate_num = mappings->get_current_crate (); + Analysis::NodeMapping mapping (crate_num, type.get_node_id (), + mappings->get_next_hir_id (crate_num), + mappings->get_next_localdef_id (crate_num)); + + translated = new HIR::ExternalTypeItem (mapping, type.get_identifier (), + type.get_locus ()); } private: diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h index 40093a2ad93..3bd0102d4dc 100644 --- a/gcc/rust/hir/tree/rust-hir-item.h +++ b/gcc/rust/hir/tree/rust-hir-item.h @@ -3152,16 +3152,20 @@ protected: class ExternalTypeItem : public ExternalItem { +public: ExternalTypeItem (Analysis::NodeMapping mappings, Identifier item_name, - Visibility vis, AST::AttrVec outer_attrs, location_t locus) + location_t locus) : ExternalItem (std::move (mappings), std::move (item_name), - std::move (vis), std::move (outer_attrs), locus) + Visibility (Visibility::PRIVATE), + /* FIXME: Is that correct? */ + {}, locus) {} ExternalTypeItem (ExternalTypeItem const &other) : ExternalItem (other) {} ExternalTypeItem (ExternalTypeItem &&other) = default; ExternalTypeItem &operator= (ExternalTypeItem &&other) = default; + ExternalTypeItem &operator= (ExternalTypeItem const &other) = default; std::string as_string () const override; @@ -3171,6 +3175,8 @@ class ExternalTypeItem : public ExternalItem ExternKind get_extern_kind () override { return ExternKind::Type; } protected: + /* Use covariance to implement clone function as returning this object + * rather than base */ ExternalTypeItem *clone_external_item_impl () const override { return new ExternalTypeItem (*this); -- 2.45.2