Enabled explicitly unknown lock levels (#5409)

* enabled explicitly unknown lock levels
* allowing "unknown" as locks pragma
* added test case for locks pragma
* updated docs on locks pragma
This commit is contained in:
Fabian Keller 2017-02-20 09:31:52 +01:00 • committed by Andreas Rumpf
commit ce4587d7b7
3 changed files with 39 additions and 1 deletions

View file

@ -582,7 +582,13 @@ proc pragmaLocks(c: PContext, it: PNode): TLockLevel =
if it.kind != nkExprColonExpr:
invalidPragma(it)
else:
if it[1].kind != nkNilLit:
case it[1].kind
of nkStrLit, nkRStrLit, nkTripleStrLit:
if it[1].strVal == "unknown":
result = UnknownLockLevel
else:
localError(it[1].info, "invalid string literal for locks pragma (only allowed string is \"unknown\")")
else:
let x = expectIntLit(c, it)
if x < 0 or x > MaxLockLevel:
localError(it[1].info, "integer must be within 0.." & $MaxLockLevel)