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 AttrC #90

Merged
merged 1 commit into from
Sep 24, 2024
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
7 changes: 3 additions & 4 deletions src/nifc/codegen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# We produce C code as a list of tokens.

import std / [assertions, syncio, tables, sets, intsets, formatfloat, strutils, packedsets]

Check warning on line 12 in src/nifc/codegen.nim

View workflow job for this annotation

GitHub Actions / linux-amd64-nim-devel (master)

imported and not used: 'formatfloat' [UnusedImport]

Check warning on line 12 in src/nifc/codegen.nim

View workflow job for this annotation

GitHub Actions / macos-amd64-nim-devel (master)

imported and not used: 'formatfloat' [UnusedImport]

Check warning on line 12 in src/nifc/codegen.nim

View workflow job for this annotation

GitHub Actions / windows-amd64-nim-devel (master)

imported and not used: 'formatfloat' [UnusedImport]
from std / os import changeFileExt, splitFile, extractFileName

import .. / lib / [bitabs, packedtrees, lineinfos]
Expand Down Expand Up @@ -201,7 +201,7 @@
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:
Expand All @@ -228,7 +228,7 @@
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:
Expand All @@ -255,7 +255,7 @@
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:
Expand Down Expand Up @@ -321,7 +321,6 @@

if t[prc.returnType].kind == Empty:
c.add "void"
c.add Space
else:
genType c, t, prc.returnType
c.add Space
Expand Down
4 changes: 3 additions & 1 deletion tests/nifc/issues.nif
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
Loading