summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2021-06-27 12:59:18 +0000
committerAlan Mackenzie <acm@muc.de>2021-06-27 12:59:18 +0000
commitef5f3d5ee7211430e5af4952042a0bebdcbc27ff (patch)
tree887d7d11a2c0d7698d7b9a253bff4d1105d60fb9
parent7722b510aae119162a20cfc67d3057152835a4ba (diff)
downloademacs-ef5f3d5ee7211430e5af4952042a0bebdcbc27ff.tar.gz
C++ Mode: Handle new keywords static_cast, etc., wrt angle brackets
* lisp/progmodes/cc-langs.el (c-<>-arglist-kwds): Add const_cast, dynamic_cast, reinterpret_cast and static_cast into this lang const. * lisp/progmodes/cc-engine.el (c-clear-<-pair-props, c-clear->-pair-props) (c-clear-<-pair-props-if-match-after, c-clear->-pair-props-if-match-before) (c-forward-<>-arglist-recur): Invalidate caches with c-trunctate-lit-pos-cache. (c-forward-<>-arglist-recur): If in a matching <...> expression, the < has a syntax-table property, but the > not, remove that property.
-rw-r--r--lisp/progmodes/cc-engine.el33
-rw-r--r--lisp/progmodes/cc-langs.el3
2 files changed, 28 insertions, 8 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 5a0f9350755..9cba87f4d91 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -6868,8 +6868,10 @@ comment at the start of cc-engine.el for more info."
(c-go-list-forward))
(when (equal (c-get-char-property (1- (point)) 'syntax-table)
c->-as-paren-syntax) ; should always be true.
- (c-unmark-<->-as-paren (1- (point))))
- (c-unmark-<->-as-paren pos))))
+ (c-unmark-<->-as-paren (1- (point)))
+ (c-truncate-lit-pos-cache (1- (point))))
+ (c-unmark-<->-as-paren pos)
+ (c-truncate-lit-pos-cache pos))))
(defun c-clear->-pair-props (&optional pos)
;; POS (default point) is at a > character. If it is marked with
@@ -6885,8 +6887,10 @@ comment at the start of cc-engine.el for more info."
(c-go-up-list-backward))
(when (equal (c-get-char-property (point) 'syntax-table)
c-<-as-paren-syntax) ; should always be true.
- (c-unmark-<->-as-paren (point)))
- (c-unmark-<->-as-paren pos))))
+ (c-unmark-<->-as-paren (point))
+ (c-truncate-lit-pos-cache (point)))
+ (c-unmark-<->-as-paren pos)
+ (c-truncate-lit-pos-cache pos))))
(defun c-clear-<>-pair-props (&optional pos)
;; POS (default point) is at a < or > character. If it has an
@@ -6919,7 +6923,8 @@ comment at the start of cc-engine.el for more info."
(equal (c-get-char-property (1- (point)) 'syntax-table)
c->-as-paren-syntax)) ; should always be true.
(c-unmark-<->-as-paren (1- (point)))
- (c-unmark-<->-as-paren pos))
+ (c-unmark-<->-as-paren pos)
+ (c-truncate-lit-pos-cache pos))
t)))
(defun c-clear->-pair-props-if-match-before (lim &optional pos)
@@ -6940,6 +6945,7 @@ comment at the start of cc-engine.el for more info."
(equal (c-get-char-property (point) 'syntax-table)
c-<-as-paren-syntax)) ; should always be true.
(c-unmark-<->-as-paren (point))
+ (c-truncate-lit-pos-cache (point))
(c-unmark-<->-as-paren pos))
t)))
@@ -7980,13 +7986,14 @@ comment at the start of cc-engine.el for more info."
;; bracket arglist. It's propagated through the return value
;; on successful completion.
(c-record-found-types c-record-found-types)
+ (syntax-table-prop-on-< (c-get-char-property (point) 'syntax-table))
;; List that collects the positions after the argument
;; separating ',' in the arglist.
arg-start-pos)
;; If the '<' has paren open syntax then we've marked it as an angle
;; bracket arglist before, so skip to the end.
(if (and (not c-parse-and-markup-<>-arglists)
- (c-get-char-property (point) 'syntax-table))
+ syntax-table-prop-on-<)
(progn
(forward-char)
@@ -8071,8 +8078,20 @@ comment at the start of cc-engine.el for more info."
(c-put-c-type-property (1- (car arg-start-pos))
'c-<>-arg-sep)
(setq arg-start-pos (cdr arg-start-pos)))
+ (when (and (not syntax-table-prop-on-<)
+ (c-get-char-property (1- (point))
+ 'syntax-table))
+ ;; Clear the now spuriously matching < of its
+ ;; syntax-table property. This could happen on
+ ;; inserting "_cast" into "static <" with C-y.
+ (save-excursion
+ (and (c-go-list-backward)
+ (eq (char-after) ?<)
+ (c-truncate-lit-pos-cache (point))
+ (c-unmark-<->-as-paren (point)))))
(c-mark-<-as-paren start)
- (c-mark->-as-paren (1- (point))))
+ (c-mark->-as-paren (1- (point)))
+ (c-truncate-lit-pos-cache start))
(setq res t)
nil)) ; Exit the loop.
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index acdb72fb7b7..86627d9502b 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -2719,7 +2719,8 @@ if this isn't nil."
`c-recognize-<>-arglists' for details. That language constant is
assumed to be set if this isn't nil."
t nil
- c++ '("template")
+ c++ '("template" "const_cast" "dynamic_cast" "reinterpret_cast"
+ "static_cast")
idl '("fixed" "string" "wstring"))
(c-lang-defconst c-<>-sexp-kwds