diff options
| author | Philipp Stephani | 2016-09-03 20:37:47 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2016-09-11 18:12:33 +0200 |
| commit | 7edaa77c5e1c0284aac4ce2dc0254d22ae6e49af (patch) | |
| tree | 56c3e91df1ae23425e8eb6d3833ace680fdc868a | |
| parent | 5fd1f7f931163ddf04f0ba0c362840fc91fba54a (diff) | |
| download | emacs-7edaa77c5e1c0284aac4ce2dc0254d22ae6e49af.tar.gz emacs-7edaa77c5e1c0284aac4ce2dc0254d22ae6e49af.zip | |
Stop calling ‘byte-compile-log-warning’
For errors, use ‘byte-compile-report-error’ instead so that the error
is registered and causes compilation to fail (Bug#24359).
For warnings, use ‘byte-compile-warn’ instead so that
‘byte-compile-error-on-warn’ is honored (Bug#24360).
* lisp/emacs-lisp/macroexp.el (macroexp--funcall-if-compiled)
(macroexp--warn-and-return): Use ‘byte-compile-warn’ instead of
‘byte-compile-log-warning’.
* lisp/emacs-lisp/bytecomp.el (byte-compile-form, byte-compile-unfold-bcf)
(byte-compile-setq, byte-compile-funcall): Use
‘byte-compile-report-error’ instead of ‘byte-compile-log-warning’.
(byte-compile-log-warning): Convert comment to documentation
string. Explain that the function shouldn’t be called directly.
(byte-compile-report-error): Add optional FILL argument.
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use)
(cconv--analyze-function, cconv-analyze-form): Use
‘byte-compile-warn’ instead of ‘byte-compile-log-warning’.
* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand): Use
‘byte-compile-warn’ instead of ‘byte-compile-log-warning’.
* lisp/subr.el (add-to-list): Use ‘byte-compile-report-error’ instead
of ‘byte-compile-log-warning’.
(do-after-load-evaluation): Use ‘byte-compile-warn’ instead of
‘byte-compile-log-warning’.
| -rw-r--r-- | lisp/emacs-lisp/byte-opt.el | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 39 | ||||
| -rw-r--r-- | lisp/emacs-lisp/cconv.el | 33 | ||||
| -rw-r--r-- | lisp/emacs-lisp/macroexp.el | 4 | ||||
| -rw-r--r-- | lisp/subr.el | 4 |
5 files changed, 42 insertions, 42 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index dbaf2bc6f6a..610c3b6c190 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el | |||
| @@ -288,8 +288,8 @@ | |||
| 288 | (if (eq (car-safe newfn) 'function) | 288 | (if (eq (car-safe newfn) 'function) |
| 289 | (byte-compile-unfold-lambda `(,(cadr newfn) ,@(cdr form))) | 289 | (byte-compile-unfold-lambda `(,(cadr newfn) ,@(cdr form))) |
| 290 | ;; This can happen because of macroexp-warn-and-return &co. | 290 | ;; This can happen because of macroexp-warn-and-return &co. |
| 291 | (byte-compile-log-warning | 291 | (byte-compile-warn |
| 292 | (format "Inlining closure %S failed" name)) | 292 | "Inlining closure %S failed" name) |
| 293 | form)))) | 293 | form)))) |
| 294 | 294 | ||
| 295 | (_ ;; Give up on inlining. | 295 | (_ ;; Give up on inlining. |
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 175690af3e8..b6bb1d6ab90 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -1160,9 +1160,13 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'." | |||
| 1160 | (compilation-forget-errors) | 1160 | (compilation-forget-errors) |
| 1161 | pt)))) | 1161 | pt)))) |
| 1162 | 1162 | ||
| 1163 | ;; Log a message STRING in `byte-compile-log-buffer'. | ||
| 1164 | ;; Also log the current function and file if not already done. | ||
| 1165 | (defun byte-compile-log-warning (string &optional fill level) | 1163 | (defun byte-compile-log-warning (string &optional fill level) |
| 1164 | "Log a message STRING in `byte-compile-log-buffer'. | ||
| 1165 | Also log the current function and file if not already done. If | ||
| 1166 | FILL is non-nil, set `warning-fill-prefix' to four spaces. LEVEL | ||
| 1167 | is the warning level (`:warning' or `:error'). Do not call this | ||
| 1168 | function directly; use `byte-compile-warn' or | ||
| 1169 | `byte-compile-report-error' instead." | ||
| 1166 | (let ((warning-prefix-function 'byte-compile-warning-prefix) | 1170 | (let ((warning-prefix-function 'byte-compile-warning-prefix) |
| 1167 | (warning-type-format "") | 1171 | (warning-type-format "") |
| 1168 | (warning-fill-prefix (if fill " "))) | 1172 | (warning-fill-prefix (if fill " "))) |
| @@ -1186,15 +1190,16 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'." | |||
| 1186 | (unless (and funcp (memq symbol byte-compile-not-obsolete-funcs)) | 1190 | (unless (and funcp (memq symbol byte-compile-not-obsolete-funcs)) |
| 1187 | (byte-compile-warn "%s" msg))))) | 1191 | (byte-compile-warn "%s" msg))))) |
| 1188 | 1192 | ||
| 1189 | (defun byte-compile-report-error (error-info) | 1193 | (defun byte-compile-report-error (error-info &optional fill) |
| 1190 | "Report Lisp error in compilation. | 1194 | "Report Lisp error in compilation. |
| 1191 | ERROR-INFO is the error data, in the form of either (ERROR-SYMBOL . DATA) | 1195 | ERROR-INFO is the error data, in the form of either (ERROR-SYMBOL . DATA) |
| 1192 | or STRING." | 1196 | or STRING. If FILL is non-nil, set ‘warning-fill-prefix’ to four spaces |
| 1197 | when printing the error message." | ||
| 1193 | (setq byte-compiler-error-flag t) | 1198 | (setq byte-compiler-error-flag t) |
| 1194 | (byte-compile-log-warning | 1199 | (byte-compile-log-warning |
| 1195 | (if (stringp error-info) error-info | 1200 | (if (stringp error-info) error-info |
| 1196 | (error-message-string error-info)) | 1201 | (error-message-string error-info)) |
| 1197 | nil :error)) | 1202 | fill :error)) |
| 1198 | 1203 | ||
| 1199 | ;;; sanity-checking arglists | 1204 | ;;; sanity-checking arglists |
| 1200 | 1205 | ||
| @@ -3025,9 +3030,8 @@ for symbols generated by the byte compiler itself." | |||
| 3025 | (pcase (cdr form) | 3030 | (pcase (cdr form) |
| 3026 | (`(',var . ,_) | 3031 | (`(',var . ,_) |
| 3027 | (when (assq var byte-compile-lexical-variables) | 3032 | (when (assq var byte-compile-lexical-variables) |
| 3028 | (byte-compile-log-warning | 3033 | (byte-compile-report-error |
| 3029 | (format-message "%s cannot use lexical var `%s'" fn var) | 3034 | (format-message "%s cannot use lexical var `%s'" fn var)))))) |
| 3030 | nil :error))))) | ||
| 3031 | (when (macroexp--const-symbol-p fn) | 3035 | (when (macroexp--const-symbol-p fn) |
| 3032 | (byte-compile-warn "`%s' called as a function" fn)) | 3036 | (byte-compile-warn "`%s' called as a function" fn)) |
| 3033 | (when (and (byte-compile-warning-enabled-p 'interactive-only) | 3037 | (when (and (byte-compile-warning-enabled-p 'interactive-only) |
| @@ -3044,9 +3048,8 @@ for symbols generated by the byte compiler itself." | |||
| 3044 | interactive-only)) | 3048 | interactive-only)) |
| 3045 | (t ".")))) | 3049 | (t ".")))) |
| 3046 | (if (eq (car-safe (symbol-function (car form))) 'macro) | 3050 | (if (eq (car-safe (symbol-function (car form))) 'macro) |
| 3047 | (byte-compile-log-warning | 3051 | (byte-compile-report-error |
| 3048 | (format "Forgot to expand macro %s in %S" (car form) form) | 3052 | (format "Forgot to expand macro %s in %S" (car form) form))) |
| 3049 | nil :error)) | ||
| 3050 | (if (and handler | 3053 | (if (and handler |
| 3051 | ;; Make sure that function exists. | 3054 | ;; Make sure that function exists. |
| 3052 | (and (functionp handler) | 3055 | (and (functionp handler) |
| @@ -3143,9 +3146,8 @@ for symbols generated by the byte compiler itself." | |||
| 3143 | (dotimes (_ (- (/ (1+ fmax2) 2) alen)) | 3146 | (dotimes (_ (- (/ (1+ fmax2) 2) alen)) |
| 3144 | (byte-compile-push-constant nil))) | 3147 | (byte-compile-push-constant nil))) |
| 3145 | ((zerop (logand fmax2 1)) | 3148 | ((zerop (logand fmax2 1)) |
| 3146 | (byte-compile-log-warning | 3149 | (byte-compile-report-error |
| 3147 | (format "Too many arguments for inlined function %S" form) | 3150 | (format "Too many arguments for inlined function %S" form)) |
| 3148 | nil :error) | ||
| 3149 | (byte-compile-discard (- alen (/ fmax2 2)))) | 3151 | (byte-compile-discard (- alen (/ fmax2 2)))) |
| 3150 | (t | 3152 | (t |
| 3151 | ;; Turn &rest args into a list. | 3153 | ;; Turn &rest args into a list. |
| @@ -3755,10 +3757,9 @@ discarding." | |||
| 3755 | (len (length args))) | 3757 | (len (length args))) |
| 3756 | (if (= (logand len 1) 1) | 3758 | (if (= (logand len 1) 1) |
| 3757 | (progn | 3759 | (progn |
| 3758 | (byte-compile-log-warning | 3760 | (byte-compile-report-error |
| 3759 | (format-message | 3761 | (format-message |
| 3760 | "missing value for `%S' at end of setq" (car (last args))) | 3762 | "missing value for `%S' at end of setq" (car (last args)))) |
| 3761 | nil :error) | ||
| 3762 | (byte-compile-form | 3763 | (byte-compile-form |
| 3763 | `(signal 'wrong-number-of-arguments '(setq ,len)) | 3764 | `(signal 'wrong-number-of-arguments '(setq ,len)) |
| 3764 | byte-compile--for-effect)) | 3765 | byte-compile--for-effect)) |
| @@ -4028,8 +4029,8 @@ that suppresses all warnings during execution of BODY." | |||
| 4028 | (progn | 4029 | (progn |
| 4029 | (mapc 'byte-compile-form (cdr form)) | 4030 | (mapc 'byte-compile-form (cdr form)) |
| 4030 | (byte-compile-out 'byte-call (length (cdr (cdr form))))) | 4031 | (byte-compile-out 'byte-call (length (cdr (cdr form))))) |
| 4031 | (byte-compile-log-warning | 4032 | (byte-compile-report-error |
| 4032 | (format-message "`funcall' called with no arguments") nil :error) | 4033 | (format-message "`funcall' called with no arguments")) |
| 4033 | (byte-compile-form '(signal 'wrong-number-of-arguments '(funcall 0)) | 4034 | (byte-compile-form '(signal 'wrong-number-of-arguments '(funcall 0)) |
| 4034 | byte-compile--for-effect))) | 4035 | byte-compile--for-effect))) |
| 4035 | 4036 | ||
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el index 9f843676357..46b5a7f342c 100644 --- a/lisp/emacs-lisp/cconv.el +++ b/lisp/emacs-lisp/cconv.el | |||
| @@ -325,9 +325,9 @@ places where they originally did not directly appear." | |||
| 325 | (var (if (not (consp binder)) | 325 | (var (if (not (consp binder)) |
| 326 | (prog1 binder (setq binder (list binder))) | 326 | (prog1 binder (setq binder (list binder))) |
| 327 | (when (cddr binder) | 327 | (when (cddr binder) |
| 328 | (byte-compile-log-warning | 328 | (byte-compile-warn |
| 329 | (format-message "Malformed `%S' binding: %S" | 329 | "Malformed `%S' binding: %S" |
| 330 | letsym binder))) | 330 | letsym binder)) |
| 331 | (setq value (cadr binder)) | 331 | (setq value (cadr binder)) |
| 332 | (car binder))) | 332 | (car binder))) |
| 333 | (new-val | 333 | (new-val |
| @@ -568,8 +568,8 @@ FORM is the parent form that binds this var." | |||
| 568 | (`(,_ nil nil nil nil) nil) | 568 | (`(,_ nil nil nil nil) nil) |
| 569 | (`((,(and var (guard (eq ?_ (aref (symbol-name var) 0)))) . ,_) | 569 | (`((,(and var (guard (eq ?_ (aref (symbol-name var) 0)))) . ,_) |
| 570 | ,_ ,_ ,_ ,_) | 570 | ,_ ,_ ,_ ,_) |
| 571 | (byte-compile-log-warning | 571 | (byte-compile-warn |
| 572 | (format-message "%s `%S' not left unused" varkind var)))) | 572 | "%s `%S' not left unused" varkind var))) |
| 573 | (pcase vardata | 573 | (pcase vardata |
| 574 | (`((,var . ,_) nil ,_ ,_ nil) | 574 | (`((,var . ,_) nil ,_ ,_ nil) |
| 575 | ;; FIXME: This gives warnings in the wrong order, with imprecise line | 575 | ;; FIXME: This gives warnings in the wrong order, with imprecise line |
| @@ -581,8 +581,8 @@ FORM is the parent form that binds this var." | |||
| 581 | (eq ?_ (aref (symbol-name var) 0)) | 581 | (eq ?_ (aref (symbol-name var) 0)) |
| 582 | ;; As a special exception, ignore "ignore". | 582 | ;; As a special exception, ignore "ignore". |
| 583 | (eq var 'ignored)) | 583 | (eq var 'ignored)) |
| 584 | (byte-compile-log-warning (format-message "Unused lexical %s `%S'" | 584 | (byte-compile-warn "Unused lexical %s `%S'" |
| 585 | varkind var)))) | 585 | varkind var))) |
| 586 | ;; If it's unused, there's no point converting it into a cons-cell, even if | 586 | ;; If it's unused, there's no point converting it into a cons-cell, even if |
| 587 | ;; it's captured and mutated. | 587 | ;; it's captured and mutated. |
| 588 | (`(,binder ,_ t t ,_) | 588 | (`(,binder ,_ t t ,_) |
| @@ -606,9 +606,9 @@ FORM is the parent form that binds this var." | |||
| 606 | (dolist (arg args) | 606 | (dolist (arg args) |
| 607 | (cond | 607 | (cond |
| 608 | ((byte-compile-not-lexical-var-p arg) | 608 | ((byte-compile-not-lexical-var-p arg) |
| 609 | (byte-compile-log-warning | 609 | (byte-compile-warn |
| 610 | (format "Lexical argument shadows the dynamic variable %S" | 610 | "Lexical argument shadows the dynamic variable %S" |
| 611 | arg))) | 611 | arg)) |
| 612 | ((eq ?& (aref (symbol-name arg) 0)) nil) ;Ignore &rest, &optional, ... | 612 | ((eq ?& (aref (symbol-name arg) 0)) nil) ;Ignore &rest, &optional, ... |
| 613 | (t (let ((varstruct (list arg nil nil nil nil))) | 613 | (t (let ((varstruct (list arg nil nil nil nil))) |
| 614 | (cl-pushnew arg byte-compile-lexical-variables) | 614 | (cl-pushnew arg byte-compile-lexical-variables) |
| @@ -690,9 +690,8 @@ and updates the data stored in ENV." | |||
| 690 | (setq forms (cddr forms)))) | 690 | (setq forms (cddr forms)))) |
| 691 | 691 | ||
| 692 | (`((lambda . ,_) . ,_) ; First element is lambda expression. | 692 | (`((lambda . ,_) . ,_) ; First element is lambda expression. |
| 693 | (byte-compile-log-warning | 693 | (byte-compile-warn |
| 694 | (format "Use of deprecated ((lambda %s ...) ...) form" (nth 1 (car form))) | 694 | "Use of deprecated ((lambda %s ...) ...) form" (nth 1 (car form))) |
| 695 | t :warning) | ||
| 696 | (dolist (exp `((function ,(car form)) . ,(cdr form))) | 695 | (dolist (exp `((function ,(car form)) . ,(cdr form))) |
| 697 | (cconv-analyze-form exp env))) | 696 | (cconv-analyze-form exp env))) |
| 698 | 697 | ||
| @@ -701,8 +700,8 @@ and updates the data stored in ENV." | |||
| 701 | (dolist (form forms) (cconv-analyze-form form env)))) | 700 | (dolist (form forms) (cconv-analyze-form form env)))) |
| 702 | 701 | ||
| 703 | ;; ((and `(quote ,v . ,_) (guard (assq v env))) | 702 | ;; ((and `(quote ,v . ,_) (guard (assq v env))) |
| 704 | ;; (byte-compile-log-warning | 703 | ;; (byte-compile-warn |
| 705 | ;; (format-message "Possible confusion variable/symbol for `%S'" v))) | 704 | ;; "Possible confusion variable/symbol for `%S'" v)) |
| 706 | 705 | ||
| 707 | (`(quote . ,_) nil) ; quote form | 706 | (`(quote . ,_) nil) ; quote form |
| 708 | (`(function . ,_) nil) ; same as quote | 707 | (`(function . ,_) nil) ; same as quote |
| @@ -719,8 +718,8 @@ and updates the data stored in ENV." | |||
| 719 | (`(condition-case ,var ,protected-form . ,handlers) | 718 | (`(condition-case ,var ,protected-form . ,handlers) |
| 720 | (cconv-analyze-form protected-form env) | 719 | (cconv-analyze-form protected-form env) |
| 721 | (when (and var (symbolp var) (byte-compile-not-lexical-var-p var)) | 720 | (when (and var (symbolp var) (byte-compile-not-lexical-var-p var)) |
| 722 | (byte-compile-log-warning | 721 | (byte-compile-warn |
| 723 | (format "Lexical variable shadows the dynamic variable %S" var))) | 722 | "Lexical variable shadows the dynamic variable %S" var)) |
| 724 | (let* ((varstruct (list var nil nil nil nil))) | 723 | (let* ((varstruct (list var nil nil nil nil))) |
| 725 | (if var (push varstruct env)) | 724 | (if var (push varstruct env)) |
| 726 | (dolist (handler handlers) | 725 | (dolist (handler handlers) |
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index 310ca29e9a1..6d89145c6a2 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el | |||
| @@ -103,7 +103,7 @@ each clause." | |||
| 103 | (defun macroexp--funcall-if-compiled (_form) | 103 | (defun macroexp--funcall-if-compiled (_form) |
| 104 | "Pseudo function used internally by macroexp to delay warnings. | 104 | "Pseudo function used internally by macroexp to delay warnings. |
| 105 | The purpose is to delay warnings to bytecomp.el, so they can use things | 105 | The purpose is to delay warnings to bytecomp.el, so they can use things |
| 106 | like `byte-compile-log-warning' to get better file-and-line-number data | 106 | like `byte-compile-warn' to get better file-and-line-number data |
| 107 | and also to avoid outputting the warning during normal execution." | 107 | and also to avoid outputting the warning during normal execution." |
| 108 | nil) | 108 | nil) |
| 109 | (put 'macroexp--funcall-if-compiled 'byte-compile | 109 | (put 'macroexp--funcall-if-compiled 'byte-compile |
| @@ -122,7 +122,7 @@ and also to avoid outputting the warning during normal execution." | |||
| 122 | (defvar macroexp--warned (make-hash-table :test #'equal :weakness 'key)) | 122 | (defvar macroexp--warned (make-hash-table :test #'equal :weakness 'key)) |
| 123 | 123 | ||
| 124 | (defun macroexp--warn-and-return (msg form &optional compile-only) | 124 | (defun macroexp--warn-and-return (msg form &optional compile-only) |
| 125 | (let ((when-compiled (lambda () (byte-compile-log-warning msg t)))) | 125 | (let ((when-compiled (lambda () (byte-compile-warn "%s" msg)))) |
| 126 | (cond | 126 | (cond |
| 127 | ((null msg) form) | 127 | ((null msg) form) |
| 128 | ((macroexp--compiling-p) | 128 | ((macroexp--compiling-p) |
diff --git a/lisp/subr.el b/lisp/subr.el index 96917b9ea96..e913e378500 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1635,7 +1635,7 @@ can do the job." | |||
| 1635 | ;; FIXME: We should also emit a warning for let-bound | 1635 | ;; FIXME: We should also emit a warning for let-bound |
| 1636 | ;; variables with dynamic binding. | 1636 | ;; variables with dynamic binding. |
| 1637 | (when (assq sym byte-compile--lexical-environment) | 1637 | (when (assq sym byte-compile--lexical-environment) |
| 1638 | (byte-compile-log-warning msg t :error)))) | 1638 | (byte-compile-report-error msg :fill)))) |
| 1639 | (code | 1639 | (code |
| 1640 | (macroexp-let2 macroexp-copyable-p x element | 1640 | (macroexp-let2 macroexp-copyable-p x element |
| 1641 | `(if ,(if compare-fn | 1641 | `(if ,(if compare-fn |
| @@ -4058,7 +4058,7 @@ This function is called directly from the C code." | |||
| 4058 | (expand-file-name | 4058 | (expand-file-name |
| 4059 | byte-compile-current-file | 4059 | byte-compile-current-file |
| 4060 | byte-compile-root-dir))) | 4060 | byte-compile-root-dir))) |
| 4061 | (byte-compile-log-warning msg)) | 4061 | (byte-compile-warn "%s" msg)) |
| 4062 | (run-with-timer 0 nil | 4062 | (run-with-timer 0 nil |
| 4063 | (lambda (msg) | 4063 | (lambda (msg) |
| 4064 | (message "%s" msg)) | 4064 | (message "%s" msg)) |