fixes #9868
This commit is contained in:
parent
9eaf99f7e6
commit
1711a60f7b
3 changed files with 23 additions and 1 deletions
|
|
@ -1975,6 +1975,22 @@ proc setMs(n: PNode, s: PSym): PNode =
|
|||
n.sons[0] = newSymNode(s)
|
||||
n.sons[0].info = n.info
|
||||
|
||||
proc semSizeof(c: PContext, n: PNode): PNode =
|
||||
if sonsLen(n) != 2:
|
||||
localError(c.config, n.info, errXExpectsTypeOrValue % "sizeof")
|
||||
else:
|
||||
n.sons[1] = semExprWithType(c, n.sons[1], {efDetermineType})
|
||||
#restoreOldStyleType(n.sons[1])
|
||||
n.typ = getSysType(c.graph, n.info, tyInt)
|
||||
|
||||
let size = getSize(c.config, n[1].typ)
|
||||
if size >= 0:
|
||||
result = newIntNode(nkIntLit, size)
|
||||
result.info = n.info
|
||||
result.typ = n.typ
|
||||
else:
|
||||
result = n
|
||||
|
||||
proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
||||
# this is a hotspot in the compiler!
|
||||
result = n
|
||||
|
|
@ -2060,6 +2076,7 @@ proc semMagic(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
|||
result = setMs(n, s)
|
||||
else:
|
||||
result = c.graph.emptyNode
|
||||
of mSizeOf: result = semSizeof(c, setMs(n, s))
|
||||
of mOmpParFor:
|
||||
checkMinSonsLen(n, 3, c.config)
|
||||
result = semDirectOp(c, n, flags)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue