summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-11-18 15:56:31 +0800
committerGitHub <noreply@github.com>2020-11-18 07:56:31 +0000
commit581bcfe29094f525d2ab4e27455bed18a3eac811 (patch)
tree7842cb4a996eb426ab62d36630ac270364a7fa81
parente6e1e9574de8c090cb9de7a809064037e2af39f7 (diff)
downloadNim-581bcfe29094f525d2ab4e27455bed18a3eac811.tar.gz
fix #6497 (#16027)
* fix #6497

* add testcase for #16027
-rw-r--r--compiler/ast.nim1
-rw-r--r--tests/ccgbugs/t16027.nim13
2 files changed, 14 insertions, 0 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 3d14aba66..c75a149c0 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -1441,6 +1441,7 @@ proc copySym*(s: PSym; id: ItemId): PSym =
   result.position = s.position
   result.loc = s.loc
   result.annex = s.annex      # BUGFIX
+  result.constraint = s.constraint
   if result.kind in {skVar, skLet, skField}:
     result.guard = s.guard
     result.bitsize = s.bitsize
diff --git a/tests/ccgbugs/t16027.nim b/tests/ccgbugs/t16027.nim
new file mode 100644
index 000000000..58f15eb6e
--- /dev/null
+++ b/tests/ccgbugs/t16027.nim
@@ -0,0 +1,13 @@
+discard """
+  ccodecheck: "__restrict__"
+  action: compile
+  joinable: false
+"""
+
+# see bug #16027
+iterator myitems(s: seq[int]): int =
+  var data {.codegenDecl: "$# __restrict__ $#".} : ptr int = nil
+  yield 1
+
+for i in @[1].myitems:
+  discard