From: Alan Mackenzie Date: Tue, 27 Sep 2022 08:39:05 +0000 (+0000) Subject: CC Mode: Don't bind max-specpdl-size when it doesn't exist or is obsolete X-Git-Tag: emacs-29.0.90~1856^2~199 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a889977e0bfc6888cc8201133aa65b8a2b773def;p=emacs.git 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*. --- 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))))