diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-09-28 19:57:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-28 13:57:47 +0200 |
commit | e33e9e4a32ea19654d1940ad0c17da8490a99f6c (patch) | |
tree | 6fe32741e95ce04fffafc02f6f591680d59ad210 /compiler | |
parent | fe8feb46c6b69d2a2b63c83af88d0f9f03a31435 (diff) | |
download | Nim-e33e9e4a32ea19654d1940ad0c17da8490a99f6c.tar.gz |
fixes #20141; dereferencing pointer to incomplete type error with cast (#20147)
Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgexprs.nim | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 8395eea8a..9b085b8ed 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2189,6 +2189,11 @@ proc genSomeCast(p: BProc, e: PNode, d: var TLoc) = elif etyp.kind == tyBool and srcTyp.kind in IntegralTypes: putIntoDest(p, d, e, "(($1) != 0)" % [rdCharLoc(a)], a.storage) else: + if etyp.kind == tyPtr: + # generates the definition of structs for casts like cast[ptr object](addr x)[] + let internalType = etyp.skipTypes({tyPtr}) + if internalType.kind == tyObject: + discard getTypeDesc(p.module, internalType) putIntoDest(p, d, e, "(($1) ($2))" % [getTypeDesc(p.module, e.typ), rdCharLoc(a)], a.storage) |