diff options
| author | Stefan Monnier | 2021-03-07 19:03:36 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2021-03-07 19:03:36 -0500 |
| commit | 26bfd0cdcf8bdf4569608227c527bebd755ef2e6 (patch) | |
| tree | b1ff4c4de4733de3f1d7c43212bc868c931c87c9 | |
| parent | 251dea693a4e5d1c33257ab3402734a8067049ec (diff) | |
| download | emacs-26bfd0cdcf8bdf4569608227c527bebd755ef2e6.tar.gz emacs-26bfd0cdcf8bdf4569608227c527bebd755ef2e6.zip | |
* lisp/cedet/semantic/bovine.el: Fix recent regression
The conversion to `lexical-binding` introduced a regression because
`bovine/c.el` relied on inspecting the local variable `lse` in one of
its callers.
(semantic-bovinate-stream): Bind `lse` dynamically, because of
`semantic-parse-region-c-mode`.
(semantic-bovinate-nonterminal-check-map): Rename from
`semantic-bovinate-nonterminal-check-obarray` to hold some other kind
of table.
(semantic-bovinate-nonterminal-check): Use a hash-table instead of an obarray.
* lisp/cedet/semantic/bovine/c.el (semantic-parse-region-c-mode):
Declare use of `lse` via dynamic scoping.
* test/lisp/cedet/semantic-utest-c.el
(semantic-test-c-preprocessor-simulation): Re-enable test.
| -rw-r--r-- | lisp/cedet/semantic/bovine.el | 27 | ||||
| -rw-r--r-- | lisp/cedet/semantic/bovine/c.el | 4 | ||||
| -rw-r--r-- | test/lisp/cedet/semantic-utest-c.el | 3 |
3 files changed, 18 insertions, 16 deletions
diff --git a/lisp/cedet/semantic/bovine.el b/lisp/cedet/semantic/bovine.el index b585e387fed..6be6dfd8dfd 100644 --- a/lisp/cedet/semantic/bovine.el +++ b/lisp/cedet/semantic/bovine.el | |||
| @@ -41,7 +41,7 @@ | |||
| 41 | 41 | ||
| 42 | ;;; Variables | 42 | ;;; Variables |
| 43 | ;; | 43 | ;; |
| 44 | (defvar-local semantic-bovinate-nonterminal-check-obarray nil | 44 | (defvar-local semantic-bovinate-nonterminal-check-map nil |
| 45 | "Obarray of streams already parsed for nonterminal symbols. | 45 | "Obarray of streams already parsed for nonterminal symbols. |
| 46 | Use this to detect infinite recursion during a parse.") | 46 | Use this to detect infinite recursion during a parse.") |
| 47 | 47 | ||
| @@ -79,21 +79,18 @@ environment of `semantic-bovinate-stream'." | |||
| 79 | (defun semantic-bovinate-nonterminal-check (stream nonterminal) | 79 | (defun semantic-bovinate-nonterminal-check (stream nonterminal) |
| 80 | "Check if STREAM not already parsed for NONTERMINAL. | 80 | "Check if STREAM not already parsed for NONTERMINAL. |
| 81 | If so abort because an infinite recursive parse is suspected." | 81 | If so abort because an infinite recursive parse is suspected." |
| 82 | (or (vectorp semantic-bovinate-nonterminal-check-obarray) | 82 | (or (hash-table-p semantic-bovinate-nonterminal-check-map) |
| 83 | (setq semantic-bovinate-nonterminal-check-obarray | 83 | (setq semantic-bovinate-nonterminal-check-map |
| 84 | (make-vector 13 nil))) | 84 | (make-hash-table :test #'eq))) |
| 85 | (let* ((nt (symbol-name nonterminal)) | 85 | (let* ((vs (gethash nonterminal semantic-bovinate-nonterminal-check-map))) |
| 86 | (vs (symbol-value | ||
| 87 | (intern-soft | ||
| 88 | nt semantic-bovinate-nonterminal-check-obarray)))) | ||
| 89 | (if (memq stream vs) | 86 | (if (memq stream vs) |
| 90 | ;; Always enter debugger to see the backtrace | 87 | ;; Always enter debugger to see the backtrace |
| 91 | (let ((debug-on-signal t) | 88 | (let ((debug-on-signal t) |
| 92 | (debug-on-error t)) | 89 | (debug-on-error t)) |
| 93 | (setq semantic-bovinate-nonterminal-check-obarray nil) | 90 | (setq semantic-bovinate-nonterminal-check-map nil) |
| 94 | (error "Infinite recursive parse suspected on %s" nt)) | 91 | (error "Infinite recursive parse suspected on %s" nonterminal)) |
| 95 | (set (intern nt semantic-bovinate-nonterminal-check-obarray) | 92 | (push stream |
| 96 | (cons stream vs))))) | 93 | (gethash nonterminal semantic-bovinate-nonterminal-check-map))))) |
| 97 | 94 | ||
| 98 | ;;;###autoload | 95 | ;;;###autoload |
| 99 | (defun semantic-bovinate-stream (stream &optional nonterminal) | 96 | (defun semantic-bovinate-stream (stream &optional nonterminal) |
| @@ -110,6 +107,9 @@ list of semantic tokens found." | |||
| 110 | (or semantic--buffer-cache | 107 | (or semantic--buffer-cache |
| 111 | (semantic-bovinate-nonterminal-check stream nonterminal)) | 108 | (semantic-bovinate-nonterminal-check stream nonterminal)) |
| 112 | 109 | ||
| 110 | ;; FIXME: `semantic-parse-region-c-mode' inspects `lse' to try and | ||
| 111 | ;; detect a recursive call (used with macroexpansion, to avoid inf-loops). | ||
| 112 | (with-suppressed-warnings ((lexical lse)) (defvar lse)) | ||
| 113 | (let* ((table semantic--parse-table) | 113 | (let* ((table semantic--parse-table) |
| 114 | (matchlist (cdr (assq nonterminal table))) | 114 | (matchlist (cdr (assq nonterminal table))) |
| 115 | (starting-stream stream) | 115 | (starting-stream stream) |
| @@ -216,7 +216,8 @@ list of semantic tokens found." | |||
| 216 | (setq cvl (cons | 216 | (setq cvl (cons |
| 217 | (if (memq (semantic-lex-token-class lse) | 217 | (if (memq (semantic-lex-token-class lse) |
| 218 | '(comment semantic-list)) | 218 | '(comment semantic-list)) |
| 219 | valdot val) cvl))) ;append unchecked value. | 219 | valdot val) |
| 220 | cvl))) ;append unchecked value. | ||
| 220 | (setq end (semantic-lex-token-end lse)) | 221 | (setq end (semantic-lex-token-end lse)) |
| 221 | ) | 222 | ) |
| 222 | (setq lte nil cvl nil)) ;No more matches, exit | 223 | (setq lte nil cvl nil)) ;No more matches, exit |
diff --git a/lisp/cedet/semantic/bovine/c.el b/lisp/cedet/semantic/bovine/c.el index 7be55ea9e10..5712f9b6df0 100644 --- a/lisp/cedet/semantic/bovine/c.el +++ b/lisp/cedet/semantic/bovine/c.el | |||
| @@ -819,7 +819,9 @@ MACRO expansion mode is handled through the nature of Emacs's non-lexical | |||
| 819 | binding of variables. | 819 | binding of variables. |
| 820 | START, END, NONTERMINAL, DEPTH, and RETURNONERRORS are the same | 820 | START, END, NONTERMINAL, DEPTH, and RETURNONERRORS are the same |
| 821 | as for the parent." | 821 | as for the parent." |
| 822 | (if (and (boundp 'lse) (or (/= start 1) (/= end (point-max)))) | 822 | ;; FIXME: We shouldn't depend on the internals of `semantic-bovinate-stream'. |
| 823 | (with-suppressed-warnings ((lexical lse)) (defvar lse)) | ||
| 824 | (if (and (boundp 'lse) (or (/= start (point-min)) (/= end (point-max)))) | ||
| 823 | (let* ((last-lexical-token lse) | 825 | (let* ((last-lexical-token lse) |
| 824 | (llt-class (semantic-lex-token-class last-lexical-token)) | 826 | (llt-class (semantic-lex-token-class last-lexical-token)) |
| 825 | (llt-fakebits (car (cdr last-lexical-token))) | 827 | (llt-fakebits (car (cdr last-lexical-token))) |
diff --git a/test/lisp/cedet/semantic-utest-c.el b/test/lisp/cedet/semantic-utest-c.el index b881cdb93b3..d08c79cad3e 100644 --- a/test/lisp/cedet/semantic-utest-c.el +++ b/test/lisp/cedet/semantic-utest-c.el | |||
| @@ -43,10 +43,9 @@ | |||
| 43 | (defvar semantic-lex-c-nested-namespace-ignore-second) | 43 | (defvar semantic-lex-c-nested-namespace-ignore-second) |
| 44 | 44 | ||
| 45 | ;;; Code: | 45 | ;;; Code: |
| 46 | ;;;###autoload | ||
| 47 | (ert-deftest semantic-test-c-preprocessor-simulation () | 46 | (ert-deftest semantic-test-c-preprocessor-simulation () |
| 48 | "Run parsing test for C from the test directory." | 47 | "Run parsing test for C from the test directory." |
| 49 | :tags '(:expensive-test :unstable) | 48 | :tags '(:expensive-test) |
| 50 | (semantic-mode 1) | 49 | (semantic-mode 1) |
| 51 | (dolist (fp semantic-utest-c-comparisons) | 50 | (dolist (fp semantic-utest-c-comparisons) |
| 52 | (let* ((semantic-lex-c-nested-namespace-ignore-second nil) | 51 | (let* ((semantic-lex-c-nested-namespace-ignore-second nil) |