emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Towards a cleaner build


From: Lars Ingebrigtsen
Subject: Re: Towards a cleaner build
Date: Fri, 17 May 2019 16:37:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

I just went ahead and finished up the two "automatic" warning
suppression things that Noam mentioned: With the following patch, a
function that has an advertised calling convention that calls itself
will check the real arglist when issuing warnings, and obsolete
functions that calls other obsolete functions won't issue any warnings.

I've built an Emacs (after rm-ing lisp/*.elc) and things seem to work
fine...

diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index 97f7fb9f79..5115edddde 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -2094,6 +2094,11 @@ Obsolete Functions
 @end example
 @end defun
 
+If a function that's marked as obsolete calls another function that's
+marked as obsolete, warnings will not be issued.  Similarly, if a
+function has declared a new calling convention, but calls itself using
+the old argument list, no warning will be output.
+
 @node Inline Functions
 @section Inline Functions
 @cindex inline functions
diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el
index 842d1d48b4..a7c0bb2eff 100644
--- a/lisp/emacs-lisp/byte-run.el
+++ b/lisp/emacs-lisp/byte-run.el
@@ -92,6 +92,11 @@ defun-declarations-alist
                    (list 'quote f) (list 'quote arglist) (list 'quote when))))
    (list 'obsolete
          #'(lambda (f _args new-name when)
+             ;; Record obsolete info immediately so that we know that
+             ;; we're compiling an obsolete function and can avoid
+             ;; giving warnings about calls to obsolete functions from
+             ;; this function.
+             (make-obsolete f new-name when)
              (list 'make-obsolete
                    (list 'quote f) (list 'quote new-name) (list 'quote when))))
    (list 'interactive-only
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index e76baf5ed0..ae8fc440fb 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -337,12 +337,19 @@ byte-compile-warnings
        (or (symbolp v)
            (null (delq nil (mapcar (lambda (x) (not (symbolp x))) v))))))
 
-(defun byte-compile-warning-enabled-p (warning)
+(defun byte-compile-warning-enabled-p (warning &optional symbol)
   "Return non-nil if WARNING is enabled, according to `byte-compile-warnings'."
-  (or (eq byte-compile-warnings t)
-      (if (eq (car byte-compile-warnings) 'not)
-          (not (memq warning byte-compile-warnings))
-        (memq warning byte-compile-warnings))))
+  ;; Don't issue a warning for SYMBOL being obsolete if called from
+  ;; within an obsolete function.
+  (and (not (and symbol
+                 (eq warning 'obsolete)
+                 byte-compile-current-form
+                 (get byte-compile-current-form 'byte-obsolete-info)
+                 (not (memq symbol byte-compile-not-obsolete-funcs))))
+       (or (eq byte-compile-warnings t)
+           (if (eq (car byte-compile-warnings) 'not)
+               (not (memq warning byte-compile-warnings))
+             (memq warning byte-compile-warnings)))))
 
 ;;;###autoload
 (defun byte-compile-disable-warning (warning)
@@ -1268,7 +1275,7 @@ byte-compile-warn
 
 (defun byte-compile-warn-obsolete (symbol)
   "Warn that SYMBOL (a variable or function) is obsolete."
-  (when (byte-compile-warning-enabled-p 'obsolete)
+  (when (byte-compile-warning-enabled-p 'obsolete symbol)
     (let* ((funcp (get symbol 'byte-obsolete-info))
            (msg (macroexp--obsolete-warning
                  symbol
@@ -1290,7 +1297,7 @@ byte-compile-report-error
 
 ;;; sanity-checking arglists
 
-(defun byte-compile-fdefinition (name macro-p)
+(defun byte-compile-fdefinition (name macro-p &optional ignore-advertised)
   ;; If a function has an entry saying (FUNCTION . t).
   ;; that means we know it is defined but we don't know how.
   ;; If a function has an entry saying (FUNCTION . nil),
@@ -1314,7 +1321,8 @@ byte-compile-fdefinition
                                        fn)
                                      advertised-signature-table t)))
             (cond
-             ((listp advertised)
+             ((and (listp advertised)
+                   (not ignore-advertised))
               (if macro-p
                   `(macro lambda ,advertised)
                 `(lambda ,advertised)))
@@ -1403,6 +1411,13 @@ byte-compile-callargs-warn
                  (byte-compile-fdefinition (car form) t)))
         (sig (byte-compile--function-signature def))
         (ncall (length (cdr form))))
+    ;; If we're in a recursive function, then ignore the advertised
+    ;; callargs when issuing warnings.
+    (when (and byte-compile-current-form
+               (eq byte-compile-current-form (car form)))
+      (setq def (or (byte-compile-fdefinition (car form) nil t)
+                   (byte-compile-fdefinition (car form) t t))
+            sig (byte-compile--function-signature def)))
     ;; Check many or unevalled from subr-arity.
     (if (and (cdr-safe sig)
             (not (numberp (cdr sig))))

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




reply via email to

[Prev in Thread] Current Thread [Next in Thread]