diff options
author | Aman Gupta <aman@tmm1.net> | 2015-09-28 14:34:36 -0700 |
---|---|---|
committer | Aman Gupta <aman@tmm1.net> | 2015-09-28 14:34:36 -0700 |
commit | 5e9ce88dafbaa0bf72a7c7c3ce11a8d827ab3200 (patch) | |
tree | 722917ba0aba672d40faeebe72d6034c49e9f15f /compiler/pragmas.nim | |
parent | bb7604c06fb2adc6999d47fdfcbf9cf2979bef9e (diff) | |
download | Nim-5e9ce88dafbaa0bf72a7c7c3ce11a8d827ab3200.tar.gz |
implement bitsize pragma for bitfields
Diffstat (limited to 'compiler/pragmas.nim')
-rw-r--r-- | compiler/pragmas.nim | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 1c51251fe..ba05b2792 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -56,7 +56,7 @@ const wInheritable, wGensym, wInject, wRequiresInit, wUnchecked, wUnion, wPacked, wBorrow, wGcSafe} fieldPragmas* = {wImportc, wExportc, wDeprecated, wExtern, - wImportCpp, wImportObjC, wError, wGuard} + wImportCpp, wImportObjC, wError, wGuard, wBitsize} varPragmas* = {wImportc, wExportc, wVolatile, wRegister, wThreadVar, wNodecl, wMagic, wHeader, wDeprecated, wCompilerproc, wDynlib, wExtern, wImportCpp, wImportObjC, wError, wNoInit, wCompileTime, wGlobal, @@ -844,6 +844,11 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int, if sym == nil: pragmaLockStmt(c, it) elif sym.typ == nil: invalidPragma(it) else: sym.typ.lockLevel = pragmaLocks(c, it) + of wBitsize: + if sym == nil or sym.kind != skField or it.kind != nkExprColonExpr: + invalidPragma(it) + else: + sym.bitsize = expectIntLit(c, it) of wGuard: if sym == nil or sym.kind notin {skVar, skLet, skField}: invalidPragma(it) |