summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2022-09-27 08:39:05 +0000
committerAlan Mackenzie <acm@muc.de>2022-09-27 08:39:05 +0000
commita889977e0bfc6888cc8201133aa65b8a2b773def (patch)
treef87ed8331d94c1b09ec09c7a46a75ce3d99c1774
parent604b541d5ce394a1e4f157a81a0cf77df98d61d0 (diff)
downloademacs-a889977e0bfc6888cc8201133aa65b8a2b773def.tar.gz
CC Mode: Don't bind max-specpdl-size when it doesn't exist or is obsolete
This is part of the changes for bug #57911. * lisp/progmodes/cc-defs.el (c-let*-maybe-max-specpdl-size): New macro. (c-get-lang-constant): Use the new macro in place of let*.
-rw-r--r--lisp/progmodes/cc-defs.el45
1 files changed, 30 insertions, 15 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index f867625480c..59927f0f2ca 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -2629,6 +2629,20 @@ fallback definition for all modes, to break the cycle).")
(defconst c-lang--novalue "novalue")
+(defmacro c-let*-maybe-max-specpdl-size (varlist &rest body)
+ ;; Like let*, but doesn't bind `max-specpdl-size' if that variable
+ ;; is in the bindings list and either doesn't exist or is obsolete.
+ (declare (debug let*) (indent 1))
+ (let ((-varlist- varlist) msp-binding)
+ (if (or (not (boundp 'max-specpdl-size))
+ (get 'max-specpdl-size 'byte-obsolete-variable))
+ (cond
+ ((memq 'max-specpdl-size -varlist-)
+ (setq -varlist- (delq 'max-specpdl-size -varlist-)))
+ ((setq msp-binding (assq 'max-specpdl-size -varlist-))
+ (setq -varlist- (delq msp-binding -varlist-)))))
+ `(let* ,varlist ,@body)))
+
(defun c-get-lang-constant (name &optional source-files mode)
;; Used by `c-lang-const'.
@@ -2669,21 +2683,22 @@ fallback definition for all modes, to break the cycle).")
;; In that case we just continue with the "assignment" before
;; the one currently being evaluated, thereby creating the
;; illusion if a `setq'-like sequence of assignments.
- (let* ((c-buffer-is-cc-mode mode)
- (source-pos
- (or (assq sym c-lang-constants-under-evaluation)
- (cons sym (vector source nil))))
- ;; Append `c-lang-constants-under-evaluation' even if an
- ;; earlier entry is found. It's only necessary to get
- ;; the recording of dependencies above correct.
- (c-lang-constants-under-evaluation
- (cons source-pos c-lang-constants-under-evaluation))
- (fallback (get mode 'c-fallback-mode))
- value
- ;; Make sure the recursion limits aren't very low
- ;; since the `c-lang-const' dependencies can go deep.
- (max-specpdl-size (max max-specpdl-size 3000))
- (max-lisp-eval-depth (max max-lisp-eval-depth 1000)))
+ (c-let*-maybe-max-specpdl-size
+ ((c-buffer-is-cc-mode mode)
+ (source-pos
+ (or (assq sym c-lang-constants-under-evaluation)
+ (cons sym (vector source nil))))
+ ;; Append `c-lang-constants-under-evaluation' even if an
+ ;; earlier entry is found. It's only necessary to get
+ ;; the recording of dependencies above correct.
+ (c-lang-constants-under-evaluation
+ (cons source-pos c-lang-constants-under-evaluation))
+ (fallback (get mode 'c-fallback-mode))
+ value
+ ;; Make sure the recursion limits aren't very low
+ ;; since the `c-lang-const' dependencies can go deep.
+ (max-specpdl-size (max max-specpdl-size 3000))
+ (max-lisp-eval-depth (max max-lisp-eval-depth 1000)))
(if (if fallback
(let ((backup-source-pos (copy-sequence (cdr source-pos))))