summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndrey R (cooldome) <ariabushenko@gmail.com>2020-11-17 18:54:14 +0000
committerAndrey R (cooldome) <ariabushenko@gmail.com>2020-11-17 18:54:14 +0000
commit1663ad77e3398fec0b5d6b00516f91565ce12cce (patch)
tree373e56a6d724f7a8ff7022d748edc2a20c317739
parent0f7f159a35bc10a43ff15bcb6c20eefdc574138e (diff)
downloadNim-1663ad77e3398fec0b5d6b00516f91565ce12cce.tar.gz
Revert "fix #15623 (#16009)"
This reverts commit 0f7f159a35bc10a43ff15bcb6c20eefdc574138e.
-rw-r--r--compiler/semfold.nim2
-rw-r--r--lib/posix/posix_linux_amd64_consts.nim2
-rw-r--r--tests/ccgbugs/t15623.nim11
-rw-r--r--tests/ccgbugs/t15623_2.nim13
4 files changed, 2 insertions, 26 deletions
diff --git a/compiler/semfold.nim b/compiler/semfold.nim
index f38359a64..9b21c5fa3 100644
--- a/compiler/semfold.nim
+++ b/compiler/semfold.nim
@@ -674,7 +674,7 @@ proc getConstExpr(m: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNode
   of nkCast:
     var a = getConstExpr(m, n[1], idgen, g)
     if a == nil: return
-    if n.typ != nil and n.typ.kind in NilableTypes and a.kind != nkNilLit:
+    if n.typ != nil and n.typ.kind in NilableTypes:
       # we allow compile-time 'cast' for pointer types:
       result = a
       result.typ = n.typ
diff --git a/lib/posix/posix_linux_amd64_consts.nim b/lib/posix/posix_linux_amd64_consts.nim
index 917c1f966..f3230f71d 100644
--- a/lib/posix/posix_linux_amd64_consts.nim
+++ b/lib/posix/posix_linux_amd64_consts.nim
@@ -365,7 +365,7 @@ const SCHED_RR* = cint(2)
 const SCHED_OTHER* = cint(0)
 
 # <semaphore.h>
-const SEM_FAILED* = nil
+const SEM_FAILED* = cast[pointer]((nil))
 
 # <signal.h>
 const SIGEV_NONE* = cint(1)
diff --git a/tests/ccgbugs/t15623.nim b/tests/ccgbugs/t15623.nim
deleted file mode 100644
index c8246c85b..000000000
--- a/tests/ccgbugs/t15623.nim
+++ /dev/null
@@ -1,11 +0,0 @@
-discard """
-  action: "compile"
-"""
-
-# bug #15623
-block:
-  echo cast[ptr int](nil)[]
-
-block:
-  var x: ref int = nil
-  echo cast[ptr int](x)[]
diff --git a/tests/ccgbugs/t15623_2.nim b/tests/ccgbugs/t15623_2.nim
deleted file mode 100644
index 4f33bc745..000000000
--- a/tests/ccgbugs/t15623_2.nim
+++ /dev/null
@@ -1,13 +0,0 @@
-discard """
-  output: '''0
-0
-'''
-"""
-
-# bug #15623
-block:
-  echo cast[int](cast[ptr int](nil))
-
-block:
-  var x: ref int = nil
-  echo cast[int](cast[ptr int](x))