Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #7363 #7371

Merged
merged 5 commits into from
Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions compiler/ccgstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ proc genAsmOrEmitStmt(p: BProc, t: PNode, isAsmStmt=false): Rope =
elif sym.kind == skType:
res.add($getTypeDesc(p.module, sym.typ))
else:
discard getTypeDesc(p.module, skipTypes(sym.typ, abstractPtrs))
var r = sym.loc.r
if r == nil:
# if no name has already been given,
Expand All @@ -975,10 +976,10 @@ proc genAsmOrEmitStmt(p: BProc, t: PNode, isAsmStmt=false): Rope =
of nkTypeOfExpr:
res.add($getTypeDesc(p.module, t.sons[i].typ))
else:
discard getTypeDesc(p.module, skipTypes(t[i].typ, abstractPtrs))
var a: TLoc
initLocExpr(p, t.sons[i], a)
initLocExpr(p, t[i], a)
res.add($a.rdLoc)
#internalError(t.sons[i].info, "genAsmOrEmitStmt()")

if isAsmStmt and hasGnuAsm in CC[cCompiler].props:
for x in splitLines(res):
Expand Down
14 changes: 14 additions & 0 deletions tests/ccgbugs/tforward_decl_only.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@ type AnotherType = object
let x = AnotherType(f: newMyRefObject("hello"))
echo $x.f


# bug #7363

type
Foo = object
a: cint
Foo2 = object
b: cint

proc f(foo: ptr Foo, foo2: ptr Foo2): cint =
if foo != nil: {.emit: "`result` = `foo`->a;".}
if foo2 != nil: {.emit: [result, " = ", foo2[], ".b;"].}

discard f(nil, nil)