Skip to content

Commit

Permalink
Prevent execution of some nr1.0 functions with nr2.0
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
powerboat9 authored and P-E-P committed Nov 22, 2024
1 parent 433a092 commit eb1c8e4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions gcc/rust/resolve/rust-name-resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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 ());

Expand All @@ -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;
Expand All @@ -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 ());

Expand All @@ -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;
Expand All @@ -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 ());

Expand All @@ -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;
Expand Down

0 comments on commit eb1c8e4

Please sign in to comment.