aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2019-04-12 20:07:03 +0000
committerAlan Mackenzie2019-04-12 20:07:03 +0000
commitcc80eeb4a43d2079963de3d181002a6a6b56560d (patch)
tree21503da66b372ca0ad5f950733bb9e27263ff33b
parent896e5802160c2797e689a7565599ebb1bd171295 (diff)
downloademacs-cc80eeb4a43d2079963de3d181002a6a6b56560d.tar.gz
emacs-cc80eeb4a43d2079963de3d181002a6a6b56560d.zip
Analyze C++ method with & or && ref-qualifier as defun, not brace list
Also firm up detection of beginning of brace list in c-looking-at-or-maybe-in-bracelist. * lisp/progmodes/cc-engine.el (c-looking-at-or-maybe-in-bracelist): On detection of such a ref-qualifier, set braceassignp to nil. When this variable has a nil value, return nil as the value of the function. On encountering a } when scanning backwards, recognise this as the end of a previous construct and stop the scan.
-rw-r--r--lisp/progmodes/cc-engine.el38
1 files changed, 26 insertions, 12 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 1a8c5164906..fc8c377f277 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -10953,7 +10953,8 @@ comment at the start of cc-engine.el for more info."
10953 (eq (char-after) ?\()) 10953 (eq (char-after) ?\())
10954 (setq braceassignp 'c++-noassign 10954 (setq braceassignp 'c++-noassign
10955 in-paren 'in-paren)) 10955 in-paren 'in-paren))
10956 ((looking-at c-pre-id-bracelist-key)) 10956 ((looking-at c-pre-id-bracelist-key)
10957 (setq braceassignp nil))
10957 ((looking-at c-return-key)) 10958 ((looking-at c-return-key))
10958 ((and (looking-at c-symbol-start) 10959 ((and (looking-at c-symbol-start)
10959 (not (looking-at c-keywords-regexp))) 10960 (not (looking-at c-keywords-regexp)))
@@ -10995,6 +10996,8 @@ comment at the start of cc-engine.el for more info."
10995 10996
10996 (setq pos (point)) 10997 (setq pos (point))
10997 (cond 10998 (cond
10999 ((not braceassignp)
11000 nil)
10998 ((and after-type-id-pos 11001 ((and after-type-id-pos
10999 (goto-char after-type-id-pos) 11002 (goto-char after-type-id-pos)
11000 (setq res (c-back-over-member-initializers)) 11003 (setq res (c-back-over-member-initializers))
@@ -11069,14 +11072,20 @@ comment at the start of cc-engine.el for more info."
11069 )))) 11072 ))))
11070 nil) 11073 nil)
11071 (t t)))))) 11074 (t t))))))
11072 (when (and (eq braceassignp 'dontknow) 11075 (when (eq braceassignp 'dontknow)
11073 (/= (c-backward-token-2 1 t lim) 0)) 11076 (cond ((and
11074 (if (save-excursion 11077 (not (eq (char-after) ?,))
11075 (and c-has-compound-literals 11078 (save-excursion
11076 (eq (c-backward-token-2 1 nil lim) 0) 11079 (c-backward-syntactic-ws)
11077 (eq (char-after) ?\())) 11080 (eq (char-before) ?})))
11078 (setq braceassignp t) 11081 (setq braceassignp nil))
11079 (setq braceassignp nil)))) 11082 ((/= (c-backward-token-2 1 t lim) 0)
11083 (if (save-excursion
11084 (and c-has-compound-literals
11085 (eq (c-backward-token-2 1 nil lim) 0)
11086 (eq (char-after) ?\()))
11087 (setq braceassignp t)
11088 (setq braceassignp nil))))))
11080 11089
11081 (cond 11090 (cond
11082 (braceassignp 11091 (braceassignp
@@ -11108,9 +11117,14 @@ comment at the start of cc-engine.el for more info."
11108 (and (consp res) 11117 (and (consp res)
11109 (eq (car res) after-type-id-pos)))))) 11118 (eq (car res) after-type-id-pos))))))
11110 (cons bufpos (or in-paren inexpr-brace-list))) 11119 (cons bufpos (or in-paren inexpr-brace-list)))
11111 ((eq (char-after) ?\;) 11120 ((or (eq (char-after) ?\;)
11112 ;; Brace lists can't contain a semicolon, so we're done. 11121 ;; Brace lists can't contain a semicolon, so we're done.
11113 ;; (setq containing-sexp nil) 11122 (save-excursion
11123 (c-backward-syntactic-ws)
11124 (eq (char-before) ?}))
11125 ;; They also can't contain a bare }, which is probably the end
11126 ;; of a function.
11127 )
11114 nil) 11128 nil)
11115 ((and (setq macro-start (point)) 11129 ((and (setq macro-start (point))
11116 (c-forward-to-cpp-define-body) 11130 (c-forward-to-cpp-define-body)