From 512dafa641ec5f772da5dbfc0889b770a895b505 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 24 Sep 2024 22:09:36 +0800 Subject: [PATCH] fixes AttrC --- src/nifc/codegen.nim | 7 +++---- tests/nifc/issues.nif | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/nifc/codegen.nim b/src/nifc/codegen.nim index 14961ea..b24940b 100644 --- a/src/nifc/codegen.nim +++ b/src/nifc/codegen.nim @@ -201,7 +201,7 @@ proc genProcPragmas(c: var GeneratedCode; t: Tree; n: NodePos; of InlineC: flags.incl isInline of AttrC: - c.add " __attribute__((" & toString(t, ch.firstSon, c.m) & "))" + c.add " __attribute__((" & c.m.lits.strings[t[ch.firstSon].litId] & "))" of NoinlineC: c.add " __attribute__((noinline))" of WasC: @@ -228,7 +228,7 @@ proc genParamPragmas(c: var GeneratedCode; t: Tree; n: NodePos) = for ch in sons(t, n): case t[ch].kind of AttrC: - c.add " __attribute__((" & toString(t, ch.firstSon, c.m) & "))" + c.add " __attribute__((" & c.m.lits.strings[t[ch.firstSon].litId] & "))" of WasC: c.add "/* " & toString(t, ch.firstSon, c.m) & " */" else: @@ -255,7 +255,7 @@ proc genVarPragmas(c: var GeneratedCode; t: Tree; n: NodePos) = of AlignC: c.add " NIM_ALIGN(" & toString(t, ch.firstSon, c.m) & ")" of AttrC: - c.add " __attribute__((" & toString(t, ch.firstSon, c.m) & "))" + c.add " __attribute__((" & c.m.lits.strings[t[ch.firstSon].litId] & "))" of WasC: c.add "/* " & toString(t, ch.firstSon, c.m) & " */" else: @@ -321,7 +321,6 @@ proc genProcDecl(c: var GeneratedCode; t: Tree; n: NodePos; isExtern: bool) = if t[prc.returnType].kind == Empty: c.add "void" - c.add Space else: genType c, t, prc.returnType c.add Space diff --git a/tests/nifc/issues.nif b/tests/nifc/issues.nif index f7066af..e927b44 100644 --- a/tests/nifc/issues.nif +++ b/tests/nifc/issues.nif @@ -89,10 +89,12 @@ (proc :foo.cs2 . . . (stmts - (scope + (scope (call printf.c "hello %s" "file 1") ) + (var :x.mangled (pragmas (attr "used") (was "x")) (bool .) .) + (asgn x.gvar (false)) (asgn x.tvar (false))