Now diagnosing missing vmctx arguments (fixes #376) (#384)

* Now diagnosing missing vmctx arguments (fixes #376).

* Added filetest for fix of #376.

* Respect formatting rules in verifier/mod.rs.

* Added parameters for each use of vmctx in test files.

* Added comments on additions on vmctx verifications.
This commit is contained in:
Grégoire Geis
2018-07-04 05:59:32 +02:00
committed by Dan Gohman
parent e5014e0fff
commit dd72b54eef
6 changed files with 52 additions and 23 deletions

View File

@@ -44,6 +44,7 @@
//! Global values
//!
//! - Detect cycles in deref(base) declarations.
//! - Detect use of 'vmctx' global value when no corresponding parameter is defined.
//!
//! TODO:
//! Ad hoc checking
@@ -170,7 +171,9 @@ impl<'a> Verifier<'a> {
}
}
// Check for cycles in the global value declarations.
// Check for:
// - cycles in the global value declarations.
// - use of 'vmctx' when no special parameter declares it.
fn verify_global_values(&self) -> VerifierResult<()> {
let mut seen = SparseSet::new();
@@ -186,6 +189,15 @@ impl<'a> Verifier<'a> {
cur = base;
}
if let ir::GlobalValueData::VMContext { .. } = self.func.global_values[cur] {
if self.func
.special_param(ir::ArgumentPurpose::VMContext)
.is_none()
{
return err!(cur, "undeclared vmctx reference {}", cur);
}
}
}
Ok(())