aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/cc-engine.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/cc-engine.el')
-rw-r--r--lisp/progmodes/cc-engine.el111
1 files changed, 65 insertions, 46 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 6572cee2cc7..dbc55f5e0ef 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -5964,7 +5964,7 @@ comment at the start of cc-engine.el for more info."
5964 ;; Recursive part of `c-forward-<>-arglist'. 5964 ;; Recursive part of `c-forward-<>-arglist'.
5965 ;; 5965 ;;
5966 ;; This function might do hidden buffer changes. 5966 ;; This function might do hidden buffer changes.
5967 (let ((start (point)) res pos tmp 5967 (let ((start (point)) res pos
5968 ;; Cover this so that any recorded found type ranges are 5968 ;; Cover this so that any recorded found type ranges are
5969 ;; automatically lost if it turns out to not be an angle 5969 ;; automatically lost if it turns out to not be an angle
5970 ;; bracket arglist. It's propagated through the return value 5970 ;; bracket arglist. It's propagated through the return value
@@ -6059,15 +6059,13 @@ comment at the start of cc-engine.el for more info."
6059 ;; Either an operator starting with '<' or a nested arglist. 6059 ;; Either an operator starting with '<' or a nested arglist.
6060 (setq pos (point)) 6060 (setq pos (point))
6061 (let (id-start id-end subres keyword-match) 6061 (let (id-start id-end subres keyword-match)
6062 (cond 6062 (cond
6063 ;; The '<' begins a multi-char operator. 6063 ;; The '<' begins a multi-char operator.
6064 ((looking-at c-<-op-cont-regexp) 6064 ((looking-at c-<-op-cont-regexp)
6065 (setq tmp (match-end 0))
6066 (goto-char (match-end 0))) 6065 (goto-char (match-end 0)))
6067 ;; We're at a nested <.....> 6066 ;; We're at a nested <.....>
6068 ((progn 6067 ((progn
6069 (setq tmp pos) 6068 (backward-char) ; to the '<'
6070 (backward-char) ; to the '<'
6071 (and 6069 (and
6072 (save-excursion 6070 (save-excursion
6073 ;; There's always an identifier before an angle 6071 ;; There's always an identifier before an angle
@@ -6087,7 +6085,9 @@ comment at the start of cc-engine.el for more info."
6087 (and keyword-match 6085 (and keyword-match
6088 (c-keyword-member 6086 (c-keyword-member
6089 (c-keyword-sym (match-string 1)) 6087 (c-keyword-sym (match-string 1))
6090 'c-<>-type-kwds))))))) 6088 'c-<>-type-kwds))))))
6089 (or subres (goto-char pos))
6090 subres)
6091 ;; It was an angle bracket arglist. 6091 ;; It was an angle bracket arglist.
6092 (setq c-record-found-types subres) 6092 (setq c-record-found-types subres)
6093 6093
@@ -6103,11 +6103,11 @@ comment at the start of cc-engine.el for more info."
6103 (c-record-ref-id (cons id-start id-end)) 6103 (c-record-ref-id (cons id-start id-end))
6104 (c-record-type-id (cons id-start id-end))))) 6104 (c-record-type-id (cons id-start id-end)))))
6105 6105
6106 ;; At a "less than" operator. 6106 ;; At a "less than" operator.
6107 (t 6107 (t
6108 (forward-char) 6108 ;; (forward-char) ; NO! We've already gone over the <.
6109 ))) 6109 )))
6110 t) ; carry on looping. 6110 t) ; carry on looping.
6111 6111
6112 ((and (not c-restricted-<>-arglists) 6112 ((and (not c-restricted-<>-arglists)
6113 (or (and (eq (char-before) ?&) 6113 (or (and (eq (char-before) ?&)
@@ -6666,49 +6666,65 @@ comment at the start of cc-engine.el for more info."
6666 (or res (goto-char here)) 6666 (or res (goto-char here))
6667 res)) 6667 res))
6668 6668
6669(defmacro c-back-over-list-of-member-inits ()
6670 ;; Go back over a list of elements, each looking like:
6671 ;; <symbol> (<expression>) ,
6672 ;; or <symbol> {<expression>} ,
6673 ;; when we are putatively immediately after a comma. Stop when we don't see
6674 ;; a comma. If either of <symbol> or bracketed <expression> is missing,
6675 ;; throw nil to 'level. If the terminating } or ) is unmatched, throw nil
6676 ;; to 'done. This is not a general purpose macro!
6677 `(while (eq (char-before) ?,)
6678 (backward-char)
6679 (c-backward-syntactic-ws)
6680 (when (not (memq (char-before) '(?\) ?})))
6681 (throw 'level nil))
6682 (when (not (c-go-list-backward))
6683 (throw 'done nil))
6684 (c-backward-syntactic-ws)
6685 (when (not (c-simple-skip-symbol-backward))
6686 (throw 'level nil))
6687 (c-backward-syntactic-ws)))
6688
6669(defun c-back-over-member-initializers () 6689(defun c-back-over-member-initializers ()
6670 ;; Test whether we are in a C++ member initializer list, and if so, go back 6690 ;; Test whether we are in a C++ member initializer list, and if so, go back
6671 ;; to the introducing ":", returning the position of the opening paren of 6691 ;; to the introducing ":", returning the position of the opening paren of
6672 ;; the function's arglist. Otherwise return nil, leaving point unchanged. 6692 ;; the function's arglist. Otherwise return nil, leaving point unchanged.
6673 (let ((here (point)) 6693 (let ((here (point))
6674 (paren-state (c-parse-state)) 6694 (paren-state (c-parse-state))
6675 res) 6695 pos level-plausible at-top-level res)
6676 6696 ;; Assume tentatively that we're at the top level. Try to go back to the
6697 ;; colon we seek.
6677 (setq res 6698 (setq res
6678 (catch 'done 6699 (catch 'done
6679 (if (not (c-at-toplevel-p)) 6700 (setq level-plausible
6680 (progn 6701 (catch 'level
6681 (while (not (c-at-toplevel-p)) 6702 (c-backward-syntactic-ws)
6682 (goto-char (c-pull-open-brace paren-state))) 6703 (when (memq (char-before) '(?\) ?}))
6683 (c-backward-syntactic-ws) 6704 (when (not (c-go-list-backward))
6684 (when (not (c-simple-skip-symbol-backward)) 6705 (throw 'done nil))
6685 (throw 'done nil)) 6706 (c-backward-syntactic-ws))
6686 (c-backward-syntactic-ws)) 6707 (when (c-simple-skip-symbol-backward)
6687 (c-backward-syntactic-ws) 6708 (c-backward-syntactic-ws))
6688 (when (memq (char-before) '(?\) ?})) 6709 (c-back-over-list-of-member-inits)
6689 (when (not (c-go-list-backward)) 6710 (and (eq (char-before) ?:)
6690 (throw 'done nil)) 6711 (c-just-after-func-arglist-p))))
6691 (c-backward-syntactic-ws)) 6712
6692 (when (c-simple-skip-symbol-backward) 6713 (while (and (not (and level-plausible
6693 (c-backward-syntactic-ws))) 6714 (setq at-top-level (c-at-toplevel-p))))
6694 6715 (setq pos (c-pull-open-brace paren-state))) ; might be a paren.
6695 (while (eq (char-before) ?,) 6716 (setq level-plausible
6696 (backward-char) 6717 (catch 'level
6697 (c-backward-syntactic-ws) 6718 (goto-char pos)
6698 6719 (c-backward-syntactic-ws)
6699 (when (not (memq (char-before) '(?\) ?}))) 6720 (when (not (c-simple-skip-symbol-backward))
6700 (throw 'done nil)) 6721 (throw 'level nil))
6701 (when (not (c-go-list-backward)) 6722 (c-backward-syntactic-ws)
6702 (throw 'done nil)) 6723 (c-back-over-list-of-member-inits)
6703 (c-backward-syntactic-ws) 6724 (and (eq (char-before) ?:)
6704 (when (not (c-simple-skip-symbol-backward)) 6725 (c-just-after-func-arglist-p)))))
6705 (throw 'done nil))
6706 (c-backward-syntactic-ws))
6707
6708 (and
6709 (eq (char-before) ?:)
6710 (c-just-after-func-arglist-p))))
6711 6726
6727 (and at-top-level level-plausible)))
6712 (or res (goto-char here)) 6728 (or res (goto-char here))
6713 res)) 6729 res))
6714 6730
@@ -8048,6 +8064,8 @@ brace.
8048 8064
8049Note that this function might do hidden buffer changes. See the 8065Note that this function might do hidden buffer changes. See the
8050comment at the start of cc-engine.el for more info." 8066comment at the start of cc-engine.el for more info."
8067 ;; Note to maintainers: this function consumes a great mass of CPU cycles.
8068 ;; Its use should thus be minimized as far as possible.
8051 (let ((paren-state (c-parse-state))) 8069 (let ((paren-state (c-parse-state)))
8052 (or (not (c-most-enclosing-brace paren-state)) 8070 (or (not (c-most-enclosing-brace paren-state))
8053 (c-search-uplist-for-classkey paren-state)))) 8071 (c-search-uplist-for-classkey paren-state))))
@@ -10052,7 +10070,8 @@ comment at the start of cc-engine.el for more info."
10052 ;; Note there is no limit on the backward search here, since member 10070 ;; Note there is no limit on the backward search here, since member
10053 ;; init lists can, in practice, be very large. 10071 ;; init lists can, in practice, be very large.
10054 ((save-excursion 10072 ((save-excursion
10055 (when (setq placeholder (c-back-over-member-initializers)) 10073 (when (and (c-major-mode-is 'c++-mode)
10074 (setq placeholder (c-back-over-member-initializers)))
10056 (setq tmp-pos (point)))) 10075 (setq tmp-pos (point))))
10057 (if (= (c-point 'bosws) (1+ tmp-pos)) 10076 (if (= (c-point 'bosws) (1+ tmp-pos))
10058 (progn 10077 (progn