Use a list instead of a set for storing the potential package imports.

This eliminates some indeterminism in the error messages, which was
causing occasional failures in CI. We don't expect this list to be
very large, so the O(n) insertion time should not be a problem.
This commit is contained in:
Martin Whitaker 2021-07-31 18:36:18 +01:00
parent 83d9b5deda
commit 389e2a3a94
3 changed files with 7 additions and 5 deletions

View File

@ -72,7 +72,7 @@ class LexicalScope {
// Packages that are wildcard imported. When identifiers from // Packages that are wildcard imported. When identifiers from
// these packages are referenced, they will be added to the // these packages are referenced, they will be added to the
// explicit imports (IEEE 1800-2012 26.3). // explicit imports (IEEE 1800-2012 26.3).
std::set<PPackage*>potential_imports; std::list<PPackage*>potential_imports;
// A task or function call may reference a task or function defined // A task or function call may reference a task or function defined
// later in the scope. So here we stash the potential imports for // later in the scope. So here we stash the potential imports for

View File

@ -478,7 +478,7 @@ static PPackage*find_potential_import(const struct vlltype&loc, LexicalScope*sco
assert(scope); assert(scope);
PPackage*found_pkg = 0; PPackage*found_pkg = 0;
for (set<PPackage*>::const_iterator cur_pkg = scope->potential_imports.begin(); for (list<PPackage*>::const_iterator cur_pkg = scope->potential_imports.begin();
cur_pkg != scope->potential_imports.end(); ++cur_pkg) { cur_pkg != scope->potential_imports.end(); ++cur_pkg) {
PPackage*search_pkg = *cur_pkg; PPackage*search_pkg = *cur_pkg;
map<perm_string,PNamedItem*>::const_iterator cur_sym map<perm_string,PNamedItem*>::const_iterator cur_sym

View File

@ -124,10 +124,12 @@ void pform_package_import(const struct vlltype&loc, PPackage*pkg, const char*ide
scope->explicit_imports[use_ident] = pkg; scope->explicit_imports[use_ident] = pkg;
} else { } else {
set<PPackage*>::const_iterator cur_pkg list<PPackage*>::const_iterator cur_pkg
= scope->potential_imports.find(pkg); = find(scope->potential_imports.begin(),
scope->potential_imports.end(),
pkg);
if (cur_pkg == scope->potential_imports.end()) if (cur_pkg == scope->potential_imports.end())
scope->potential_imports.insert(pkg); scope->potential_imports.push_back(pkg);
} }
} }