From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: Bogus byte-compiler warnings Date: Thu, 16 Nov 2006 12:31:17 -0500 Message-ID: <87zmar47tm.fsf@cyd.mit.edu> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1163698299 1365 80.91.229.2 (16 Nov 2006 17:31:39 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 16 Nov 2006 17:31:39 +0000 (UTC) Cc: Reiner Steib , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 16 18:31:34 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Gkl5F-0001U3-DE for ged-emacs-devel@m.gmane.org; Thu, 16 Nov 2006 18:31:29 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gkl5E-0007kh-CZ for ged-emacs-devel@m.gmane.org; Thu, 16 Nov 2006 12:31:28 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gkl4w-0007hE-Pe for emacs-devel@gnu.org; Thu, 16 Nov 2006 12:31:10 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gkl4s-0007aJ-0u for emacs-devel@gnu.org; Thu, 16 Nov 2006 12:31:09 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gkl4r-0007Zs-Qj for emacs-devel@gnu.org; Thu, 16 Nov 2006 12:31:05 -0500 Original-Received: from [199.232.41.67] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1Gkl4n-0007gD-HK; Thu, 16 Nov 2006 12:31:01 -0500 Original-Received: from [18.19.1.138] (helo=cyd.mit.edu) by mx20.gnu.org with esmtp (Exim 4.52) id 1Gkl4l-00033i-IN; Thu, 16 Nov 2006 12:30:59 -0500 Original-Received: by cyd.mit.edu (Postfix, from userid 1000) id 708854E449; Thu, 16 Nov 2006 12:31:17 -0500 (EST) Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Mon\, 13 Nov 2006 04\:44\:32 -0500") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.90 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:62383 Archived-At: Richard Stallman writes: > > (defun foo-func-1 () > > (when (and (boundp 'foo-var) > > (fboundp 'foo-1)) > > (foo-1))) > > foo-1 will not be called if it's not fbound. (Emacs complains about > both, foo-1 and foo-2). > > The reason there is a warning for foo-1 is that the code in the > compiler to avoid such warnings recognizes only the simpler case (such > as foo-2) and not the more complex case that foo-1 is. > > I would not mind if that code were made smarter. How bout this patch? *** emacs/lisp/emacs-lisp/bytecomp.el.~2.186.~ 2006-07-07 13:45:48.000000000 -0400 --- emacs/lisp/emacs-lisp/bytecomp.el 2006-11-16 12:27:07.000000000 -0500 *************** *** 3398,3432 **** If CONDITION's value is (not (featurep 'emacs)) or (featurep 'xemacs), that suppresses all warnings during execution of BODY." (declare (indent 1) (debug t)) ! `(let* ((fbound ! (if (eq 'fboundp (car-safe ,condition)) ! (and (eq 'quote (car-safe (nth 1 ,condition))) ! ;; Ignore if the symbol is already on the ! ;; unresolved list. ! (not (assq (nth 1 (nth 1 ,condition)) ; the relevant symbol ! byte-compile-unresolved-functions)) ! (nth 1 (nth 1 ,condition))))) ! (bound (if (or (eq 'boundp (car-safe ,condition)) ! (eq 'default-boundp (car-safe ,condition))) ! (and (eq 'quote (car-safe (nth 1 ,condition))) ! (nth 1 (nth 1 ,condition))))) ! ;; Maybe add to the bound list. ! (byte-compile-bound-variables ! (if bound ! (cons bound byte-compile-bound-variables) ! byte-compile-bound-variables)) ! ;; Suppress all warnings, for code not used in Emacs. ! (byte-compile-warnings (if (member ,condition '((featurep 'xemacs) (not (featurep 'emacs)))) ! nil byte-compile-warnings))) (unwind-protect (progn ,@body) ;; Maybe remove the function symbol from the unresolved list. ! (if fbound ! (setq byte-compile-unresolved-functions ! (delq (assq fbound byte-compile-unresolved-functions) ! byte-compile-unresolved-functions)))))) (defun byte-compile-if (form) (byte-compile-form (car (cdr form))) --- 3398,3438 ---- If CONDITION's value is (not (featurep 'emacs)) or (featurep 'xemacs), that suppresses all warnings during execution of BODY." (declare (indent 1) (debug t)) ! `(let* ((byte-compile-warnings ! ;; Suppress all warnings, for code not used in Emacs. (if (member ,condition '((featurep 'xemacs) (not (featurep 'emacs)))) ! nil byte-compile-warnings)) ! (byte-compile-bound-variables byte-compile-bound-variables) ! binding fbound-list) ! (mapc (lambda (subcondition) ! (cond ((eq 'fboundp (car-safe subcondition)) ! (setq binding (and (eq 'quote (car-safe (nth 1 subcondition))) ! ;; Ignore if the symbol is already on the ! ;; unresolved list. ! (not (assq (nth 1 (nth 1 subcondition)) ! byte-compile-unresolved-functions)) ! (nth 1 (nth 1 subcondition)))) ! (if binding (setq fbound-list (cons binding fbound-list)))) ! ((or (eq 'boundp (car-safe subcondition)) ! (eq 'default-boundp (car-safe subcondition))) ! (setq binding (and (eq 'quote (car-safe (nth 1 subcondition))) ! (nth 1 (nth 1 subcondition)))) ! (if binding (setq byte-compile-bound-variables ! (cons binding byte-compile-bound-variables)))))) ! ;; Inspect each element in an `and' condition; otherwise, ! ;; inspect the condition itself. ! (if (eq 'and (car-safe ,condition)) ! (cdr-safe ,condition) ! (list ,condition))) (unwind-protect (progn ,@body) ;; Maybe remove the function symbol from the unresolved list. ! (mapc (lambda (fun) ! (setq byte-compile-unresolved-functions ! (delq (assq fun byte-compile-unresolved-functions) ! byte-compile-unresolved-functions))) ! fbound-list)))) (defun byte-compile-if (form) (byte-compile-form (car (cdr form)))