aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2022-09-27 08:39:05 +0000
committerAlan Mackenzie2022-09-27 08:39:05 +0000
commita889977e0bfc6888cc8201133aa65b8a2b773def (patch)
treef87ed8331d94c1b09ec09c7a46a75ce3d99c1774
parent604b541d5ce394a1e4f157a81a0cf77df98d61d0 (diff)
downloademacs-a889977e0bfc6888cc8201133aa65b8a2b773def.tar.gz
emacs-a889977e0bfc6888cc8201133aa65b8a2b773def.zip
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).")
2629 2629
2630(defconst c-lang--novalue "novalue") 2630(defconst c-lang--novalue "novalue")
2631 2631
2632(defmacro c-let*-maybe-max-specpdl-size (varlist &rest body)
2633 ;; Like let*, but doesn't bind `max-specpdl-size' if that variable
2634 ;; is in the bindings list and either doesn't exist or is obsolete.
2635 (declare (debug let*) (indent 1))
2636 (let ((-varlist- varlist) msp-binding)
2637 (if (or (not (boundp 'max-specpdl-size))
2638 (get 'max-specpdl-size 'byte-obsolete-variable))
2639 (cond
2640 ((memq 'max-specpdl-size -varlist-)
2641 (setq -varlist- (delq 'max-specpdl-size -varlist-)))
2642 ((setq msp-binding (assq 'max-specpdl-size -varlist-))
2643 (setq -varlist- (delq msp-binding -varlist-)))))
2644 `(let* ,varlist ,@body)))
2645
2632(defun c-get-lang-constant (name &optional source-files mode) 2646(defun c-get-lang-constant (name &optional source-files mode)
2633 ;; Used by `c-lang-const'. 2647 ;; Used by `c-lang-const'.
2634 2648
@@ -2669,21 +2683,22 @@ fallback definition for all modes, to break the cycle).")
2669 ;; In that case we just continue with the "assignment" before 2683 ;; In that case we just continue with the "assignment" before
2670 ;; the one currently being evaluated, thereby creating the 2684 ;; the one currently being evaluated, thereby creating the
2671 ;; illusion if a `setq'-like sequence of assignments. 2685 ;; illusion if a `setq'-like sequence of assignments.
2672 (let* ((c-buffer-is-cc-mode mode) 2686 (c-let*-maybe-max-specpdl-size
2673 (source-pos 2687 ((c-buffer-is-cc-mode mode)
2674 (or (assq sym c-lang-constants-under-evaluation) 2688 (source-pos
2675 (cons sym (vector source nil)))) 2689 (or (assq sym c-lang-constants-under-evaluation)
2676 ;; Append `c-lang-constants-under-evaluation' even if an 2690 (cons sym (vector source nil))))
2677 ;; earlier entry is found. It's only necessary to get 2691 ;; Append `c-lang-constants-under-evaluation' even if an
2678 ;; the recording of dependencies above correct. 2692 ;; earlier entry is found. It's only necessary to get
2679 (c-lang-constants-under-evaluation 2693 ;; the recording of dependencies above correct.
2680 (cons source-pos c-lang-constants-under-evaluation)) 2694 (c-lang-constants-under-evaluation
2681 (fallback (get mode 'c-fallback-mode)) 2695 (cons source-pos c-lang-constants-under-evaluation))
2682 value 2696 (fallback (get mode 'c-fallback-mode))
2683 ;; Make sure the recursion limits aren't very low 2697 value
2684 ;; since the `c-lang-const' dependencies can go deep. 2698 ;; Make sure the recursion limits aren't very low
2685 (max-specpdl-size (max max-specpdl-size 3000)) 2699 ;; since the `c-lang-const' dependencies can go deep.
2686 (max-lisp-eval-depth (max max-lisp-eval-depth 1000))) 2700 (max-specpdl-size (max max-specpdl-size 3000))
2701 (max-lisp-eval-depth (max max-lisp-eval-depth 1000)))
2687 2702
2688 (if (if fallback 2703 (if (if fallback
2689 (let ((backup-source-pos (copy-sequence (cdr source-pos)))) 2704 (let ((backup-source-pos (copy-sequence (cdr source-pos))))