summary refs log tree commit diff stats
path: root/compiler/pragmas.nim
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2018-10-13 15:52:28 -0700
committerAndreas Rumpf <rumpf_a@web.de>2018-10-14 00:52:28 +0200
commit745f1642d6faf3a30543cd76196a7462d7460d6d (patch)
treec94ae73ba3e662a2c873aa8c9a85654c3aa3bbc4 /compiler/pragmas.nim
parent3e2d8c1c535d75d3451ce016e7b54cb609c01e45 (diff)
downloadNim-745f1642d6faf3a30543cd76196a7462d7460d6d.tar.gz
implement sizeof and alignof operator (manually squashed #5664) (#9356)
Diffstat (limited to 'compiler/pragmas.nim')
-rw-r--r--compiler/pragmas.nim4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim
index eda52ab02..c69da1813 100644
--- a/compiler/pragmas.nim
+++ b/compiler/pragmas.nim
@@ -803,9 +803,11 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
         if sym.typ == nil: invalidPragma(c, it)
         var size = expectIntLit(c, it)
         if not isPowerOfTwo(size) or size <= 0 or size > 8:
-          localError(c.config, it.info, "power of two expected")
+          localError(c.config, it.info, "size may only be 1, 2, 4 or 8")
         else:
           sym.typ.size = size
+          # TODO, this is not correct
+          sym.typ.align = int16(size)
       of wNodecl:
         noVal(c, it)
         incl(sym.loc.flags, lfNoDecl)