From eb1c8e462d4703cd938282aa23db35ddb2faa82b Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Thu, 21 Nov 2024 15:28:46 -0500 Subject: [PATCH] Prevent execution of some nr1.0 functions with nr2.0 gcc/rust/ChangeLog: * resolve/rust-name-resolver.cc: Include options.txt. (Resolver::insert_resolved_name): Assert that name resolution 2.0 is disabled. (Resolver::lookup_resolved_name): Likewise. (Resolver::insert_resolved_type): Likewise. (Resolver::lookup_resolved_type): Likewise. (Resolver::insert_resolved_label): Likewise. (Resolver::lookup_resolved_label): Likewise. (Resolver::insert_resolved_macro): Likewise. (Resolver::lookup_resolved_macro): Likewise. (Resolver::insert_resolved_misc): Likewise. (Resolver::lookup_resolved_misc): Likewise. Signed-off-by: Owen Avery --- gcc/rust/resolve/rust-name-resolver.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gcc/rust/resolve/rust-name-resolver.cc b/gcc/rust/resolve/rust-name-resolver.cc index de8d29c24857..6b131ad374d5 100644 --- a/gcc/rust/resolve/rust-name-resolver.cc +++ b/gcc/rust/resolve/rust-name-resolver.cc @@ -19,6 +19,9 @@ #include "rust-name-resolver.h" #include "rust-ast-full.h" +// for flag_name_resolution_2_0 +#include "options.h" + namespace Rust { namespace Resolver { @@ -468,6 +471,7 @@ Resolver::setup_builtin (const std::string &name, TyTy::BaseType *tyty) void Resolver::insert_resolved_name (NodeId refId, NodeId defId) { + rust_assert (!flag_name_resolution_2_0); resolved_names[refId] = defId; get_name_scope ().append_reference_for_def (refId, defId); insert_captured_item (defId); @@ -476,6 +480,7 @@ Resolver::insert_resolved_name (NodeId refId, NodeId defId) bool Resolver::lookup_resolved_name (NodeId refId, NodeId *defId) { + rust_assert (!flag_name_resolution_2_0); auto it = resolved_names.find (refId); if (it == resolved_names.end ()) return false; @@ -489,6 +494,7 @@ Resolver::insert_resolved_type (NodeId refId, NodeId defId) { // auto it = resolved_types.find (refId); // rust_assert (it == resolved_types.end ()); + rust_assert (!flag_name_resolution_2_0); resolved_types[refId] = defId; get_type_scope ().append_reference_for_def (refId, defId); @@ -497,6 +503,7 @@ Resolver::insert_resolved_type (NodeId refId, NodeId defId) bool Resolver::lookup_resolved_type (NodeId refId, NodeId *defId) { + rust_assert (!flag_name_resolution_2_0); auto it = resolved_types.find (refId); if (it == resolved_types.end ()) return false; @@ -508,6 +515,7 @@ Resolver::lookup_resolved_type (NodeId refId, NodeId *defId) void Resolver::insert_resolved_label (NodeId refId, NodeId defId) { + rust_assert (!flag_name_resolution_2_0); auto it = resolved_labels.find (refId); rust_assert (it == resolved_labels.end ()); @@ -518,6 +526,7 @@ Resolver::insert_resolved_label (NodeId refId, NodeId defId) bool Resolver::lookup_resolved_label (NodeId refId, NodeId *defId) { + rust_assert (!flag_name_resolution_2_0); auto it = resolved_labels.find (refId); if (it == resolved_labels.end ()) return false; @@ -529,6 +538,7 @@ Resolver::lookup_resolved_label (NodeId refId, NodeId *defId) void Resolver::insert_resolved_macro (NodeId refId, NodeId defId) { + rust_assert (!flag_name_resolution_2_0); auto it = resolved_macros.find (refId); rust_assert (it == resolved_macros.end ()); @@ -539,6 +549,7 @@ Resolver::insert_resolved_macro (NodeId refId, NodeId defId) bool Resolver::lookup_resolved_macro (NodeId refId, NodeId *defId) { + rust_assert (!flag_name_resolution_2_0); auto it = resolved_macros.find (refId); if (it == resolved_macros.end ()) return false; @@ -550,6 +561,7 @@ Resolver::lookup_resolved_macro (NodeId refId, NodeId *defId) void Resolver::insert_resolved_misc (NodeId refId, NodeId defId) { + rust_assert (!flag_name_resolution_2_0); auto it = misc_resolved_items.find (refId); rust_assert (it == misc_resolved_items.end ()); @@ -559,6 +571,7 @@ Resolver::insert_resolved_misc (NodeId refId, NodeId defId) bool Resolver::lookup_resolved_misc (NodeId refId, NodeId *defId) { + rust_assert (!flag_name_resolution_2_0); auto it = misc_resolved_items.find (refId); if (it == misc_resolved_items.end ()) return false;