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 #21116; always mangles the param #21121

Merged
merged 4 commits into from
Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 1 addition & 5 deletions compiler/ccgtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ proc fillBackendName(m: BModule; s: PSym) =
writeMangledName(m.ndi, s, m.config)

proc fillParamName(m: BModule; s: PSym) =
## we cannot use 'sigConflicts' here since we have a BModule, not a BProc.
## Fortunately C's scoping rules are sane enough so that that doesn't
## cause any trouble.
if s.loc.r == "":
var res = s.name.s.mangle
res.add idOrSig(s, res, m.sigConflicts)
# Take into account if HCR is on because of the following scenario:
# if a module gets imported and it has some more importc symbols in it,
# some param names might receive the "_0" suffix to distinguish from what
Expand All @@ -69,8 +67,6 @@ proc fillParamName(m: BModule; s: PSym) =
# and a function called in main or proxy uses `socket` as a parameter name.
# That would lead to either needing to reload `proxy` or to overwrite the
# executable file for the main module, which is running (or both!) -> error.
if m.hcrOn or isKeyword(s.name) or m.g.config.cppDefines.contains(res):
res.add "_0"
s.loc.r = res.rope
writeMangledName(m.ndi, s, m.config)

Expand Down
11 changes: 11 additions & 0 deletions tests/ccgbugs/t21116.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
discard """
target: "c cpp"
disabled: windows
"""
# bug #21116
import posix

proc p(glob: string) =
discard posix.glob(glob, 0, nil, nil)

p "*"
ringabout marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion tests/ccgbugs/tnoalias.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
ccodecheck: "\\i@'NI* NIM_NOALIAS field;' @'NIM_CHAR* NIM_NOALIAS x,' @'void* NIM_NOALIAS q'"
ccodecheck: "\\i@'NI* NIM_NOALIAS field;' @'NIM_CHAR* NIM_NOALIAS x__0qEngDE9aYoYsF8tWnyPacw,' @'void* NIM_NOALIAS q'"
"""

type
Expand Down