From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: Towards a cleaner build Date: Fri, 17 May 2019 16:37:49 +0200 Message-ID: References: <831s0xd3z1.fsf@gnu.org> <83pnohbhny.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="48910"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Eli Zaretskii , Stefan Monnier , Emacs developers To: Noam Postavsky Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 17 16:38:35 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hRe0I-000CYC-77 for ged-emacs-devel@m.gmane.org; Fri, 17 May 2019 16:38:34 +0200 Original-Received: from localhost ([127.0.0.1]:49573 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRe0H-0008Iy-8N for ged-emacs-devel@m.gmane.org; Fri, 17 May 2019 10:38:33 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:44722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRdzg-0008Ic-81 for emacs-devel@gnu.org; Fri, 17 May 2019 10:37:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRdzf-0003Al-0L for emacs-devel@gnu.org; Fri, 17 May 2019 10:37:56 -0400 Original-Received: from quimby.gnus.org ([80.91.231.51]:36150) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hRdze-00038x-Pt; Fri, 17 May 2019 10:37:54 -0400 Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=stories) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hRdzZ-0003q0-B2; Fri, 17 May 2019 16:37:51 +0200 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUPCgH//wH//wTGtxD/ /wL//wD//wP18gYTPlgZAAACTElEQVQ4jb1Tu47bMBAkoCI1AerqHGVYreEFjjXtBVULsD4gskC3 Z1HQ/n5mZSO+JEib8UPkznL2JZpG5kUA/EXJWSS3MrerN/RBgYBlDQBRKYWoOc5GgmBfZGHYcTKU RkqRo5l4ypFt3fe1tS5m5inlMWcQPMFggYvj6GJ0acw8mcTYceTa6gdg56Z0yoax3vz1AQ/LNrJL 3riHse7tBURkGBE1bwRk7DAMD48eWjalbDaZCHuvrBIWBLKCeVB/oMYXdkRiBlEPfa82iz+sN4qt Mz2SHF4nIFkP9mJPRkVtP/wCWjBAzBlEqF8nHkD4N/PF+QmVAPHV80loEs5sOda/EwijhP3jxFYy iB51v8L3CIH6OWl3o9aOkPWzycxp782EJ0ftkA4Aa96Pfu+9+aHrTZbVJWX/JDBz7GuV4YxB8OhH n0Gov448OhUHJp9zHr3Ba8G2u1s7chcmdpzHEWJK4MChwljzZzUhB3hmfhvN9iYcKh3dd7OkgBSc SzGZiBM3CkjWnWm+mgUpMIKYnXWprO0CdfHSmCWXwBoDsrdwozXyiXZtK+v4WW1ZIYRIK0irIxGf ZSphVsLlPd7x8s7cUSjKYYvqtUDR68G5w6MK0hYhv1WecVPkHvlM2xXS3wzCuq4EWtASEASfleiw EbbB+q5tL3rlyDf0kHIyn+gd3X0rVMKR1uYhFbuy6yhifLGhBld1aagcQRS6x3NgHeAZxFrCFZcW hKlEGiUiCpnp4xquoSUlFJWmyDcjxpChb/5wfBJ/o/oX8V/wE4vO7qgaDhi1AAAAAElFTkSuQmCC In-Reply-To: (Lars Ingebrigtsen's message of "Fri, 17 May 2019 16:07:08 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 80.91.231.51 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:236674 Archived-At: 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