summary refs log tree commit diff stats
path: root/compiler/pragmas.nim
diff options
context:
space:
mode:
authorAman Gupta <aman@tmm1.net>2015-09-28 14:34:36 -0700
committerAman Gupta <aman@tmm1.net>2015-09-28 14:34:36 -0700
commit5e9ce88dafbaa0bf72a7c7c3ce11a8d827ab3200 (patch)
tree722917ba0aba672d40faeebe72d6034c49e9f15f /compiler/pragmas.nim
parentbb7604c06fb2adc6999d47fdfcbf9cf2979bef9e (diff)
downloadNim-5e9ce88dafbaa0bf72a7c7c3ce11a8d827ab3200.tar.gz
implement bitsize pragma for bitfields
Diffstat (limited to 'compiler/pragmas.nim')
-rw-r--r--compiler/pragmas.nim7
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)