added missing .noalias support for object fields (#15445)
This commit is contained in:
parent
6b3654c48d
commit
b703f02ad2
2 changed files with 11 additions and 4 deletions
|
|
@ -564,19 +564,21 @@ proc genRecordFieldsAux(m: BModule, n: PNode,
|
||||||
# have to recurse via 'getTypeDescAux'. And not doing so prevents problems
|
# have to recurse via 'getTypeDescAux'. And not doing so prevents problems
|
||||||
# with heavily templatized C++ code:
|
# with heavily templatized C++ code:
|
||||||
if not isImportedCppType(rectype):
|
if not isImportedCppType(rectype):
|
||||||
|
let noAlias = if sfNoalias in field.flags: ~" NIM_NOALIAS" else: nil
|
||||||
|
|
||||||
let fieldType = field.loc.lode.typ.skipTypes(abstractInst)
|
let fieldType = field.loc.lode.typ.skipTypes(abstractInst)
|
||||||
if fieldType.kind == tyUncheckedArray:
|
if fieldType.kind == tyUncheckedArray:
|
||||||
result.addf("$1 $2[SEQ_DECL_SIZE];$n",
|
result.addf("$1 $2[SEQ_DECL_SIZE];$n",
|
||||||
[getTypeDescAux(m, fieldType.elemType, check, skField), sname])
|
[getTypeDescAux(m, fieldType.elemType, check, skField), sname])
|
||||||
elif fieldType.kind == tySequence:
|
elif fieldType.kind == tySequence:
|
||||||
# we need to use a weak dependency here for trecursive_table.
|
# we need to use a weak dependency here for trecursive_table.
|
||||||
result.addf("$1 $2;$n", [getTypeDescWeak(m, field.loc.t, check, skField), sname])
|
result.addf("$1$3 $2;$n", [getTypeDescWeak(m, field.loc.t, check, skField), sname, noAlias])
|
||||||
elif field.bitsize != 0:
|
elif field.bitsize != 0:
|
||||||
result.addf("$1 $2:$3;$n", [getTypeDescAux(m, field.loc.t, check, skField), sname, rope($field.bitsize)])
|
result.addf("$1$4 $2:$3;$n", [getTypeDescAux(m, field.loc.t, check, skField), sname, rope($field.bitsize), noAlias])
|
||||||
else:
|
else:
|
||||||
# don't use fieldType here because we need the
|
# don't use fieldType here because we need the
|
||||||
# tyGenericInst for C++ template support
|
# tyGenericInst for C++ template support
|
||||||
result.addf("$1 $2;$n", [getTypeDescAux(m, field.loc.t, check, skField), sname])
|
result.addf("$1$3 $2;$n", [getTypeDescAux(m, field.loc.t, check, skField), sname, noAlias])
|
||||||
else: internalError(m.config, n.info, "genRecordFieldsAux()")
|
else: internalError(m.config, n.info, "genRecordFieldsAux()")
|
||||||
|
|
||||||
proc getRecordFields(m: BModule, typ: PType, check: var IntSet): Rope =
|
proc getRecordFields(m: BModule, typ: PType, check: var IntSet): Rope =
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,13 @@
|
||||||
discard """
|
discard """
|
||||||
ccodecheck: "\\i@'NIM_CHAR* NIM_NOALIAS x,' @'void* NIM_NOALIAS q'"
|
ccodecheck: "\\i@'NI* NIM_NOALIAS field;' @'NIM_CHAR* NIM_NOALIAS x,' @'void* NIM_NOALIAS q'"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
type
|
||||||
|
BigNum = object
|
||||||
|
field {.noalias.}: ptr UncheckedArray[int]
|
||||||
|
|
||||||
proc p(x {.noalias.}: openArray[char]) =
|
proc p(x {.noalias.}: openArray[char]) =
|
||||||
var q {.noalias.}: pointer = unsafeAddr(x[0])
|
var q {.noalias.}: pointer = unsafeAddr(x[0])
|
||||||
|
|
||||||
|
var bn: BigNum
|
||||||
p "abc"
|
p "abc"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue