From 2b5e775cc5b8ff7ad8541776bdb168e459da4a8e Mon Sep 17 00:00:00 2001
From: gerd <gerd>
Date: Sun, 26 Oct 2003 10:27:58 +0000
Subject: [PATCH] 	(eval '(block b3                  (max (return-from b3
 1)                  (if (unwind-protect (unwind-protect 2)) 3 4)))) 	 =>
 nil is not of type c::ref

	* src/compiler/envanal.lisp (emit-cleanups): Don't generate
	a %funcall If second arg of :unwind-protect cleanup is unused.
	Found by Paul Dietz.
---
 compiler/envanal.lisp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/compiler/envanal.lisp b/compiler/envanal.lisp
index 49fb44f45..76ed7f811 100644
--- a/compiler/envanal.lisp
+++ b/compiler/envanal.lisp
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/envanal.lisp,v 1.32 2003/10/04 12:21:49 gerd Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/envanal.lisp,v 1.33 2003/10/26 10:27:58 gerd Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -348,9 +348,11 @@
 	     (code `(%catch-breakup)))
 	    (:unwind-protect
 	     (code `(%unwind-protect-breakup))
-	     (let ((fun (ref-leaf (continuation-use (second args)))))
-	       (reanalyze-funs fun)
-	       (code `(%funcall ,fun))))
+	     (let ((use (continuation-use (second args))))
+	       (when use
+		 (let ((fun (ref-leaf use)))
+		   (reanalyze-funs fun)
+		   (code `(%funcall ,fun))))))
 	    ((:block :tagbody)
 	     (cond (*converting-for-interpreter*
 		    ;; Avoid duplicates, as the interpreter expects just one
-- 
GitLab