summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2019-04-12 20:07:03 +0000
committerAlan Mackenzie <acm@muc.de>2019-04-12 20:07:03 +0000
commitcc80eeb4a43d2079963de3d181002a6a6b56560d (patch)
tree21503da66b372ca0ad5f950733bb9e27263ff33b
parent896e5802160c2797e689a7565599ebb1bd171295 (diff)
downloademacs-cc80eeb4a43d2079963de3d181002a6a6b56560d.tar.gz
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."
(eq (char-after) ?\())
(setq braceassignp 'c++-noassign
in-paren 'in-paren))
- ((looking-at c-pre-id-bracelist-key))
+ ((looking-at c-pre-id-bracelist-key)
+ (setq braceassignp nil))
((looking-at c-return-key))
((and (looking-at c-symbol-start)
(not (looking-at c-keywords-regexp)))
@@ -10995,6 +10996,8 @@ comment at the start of cc-engine.el for more info."
(setq pos (point))
(cond
+ ((not braceassignp)
+ nil)
((and after-type-id-pos
(goto-char after-type-id-pos)
(setq res (c-back-over-member-initializers))
@@ -11069,14 +11072,20 @@ comment at the start of cc-engine.el for more info."
))))
nil)
(t t))))))
- (when (and (eq braceassignp 'dontknow)
- (/= (c-backward-token-2 1 t lim) 0))
- (if (save-excursion
- (and c-has-compound-literals
- (eq (c-backward-token-2 1 nil lim) 0)
- (eq (char-after) ?\()))
- (setq braceassignp t)
- (setq braceassignp nil))))
+ (when (eq braceassignp 'dontknow)
+ (cond ((and
+ (not (eq (char-after) ?,))
+ (save-excursion
+ (c-backward-syntactic-ws)
+ (eq (char-before) ?})))
+ (setq braceassignp nil))
+ ((/= (c-backward-token-2 1 t lim) 0)
+ (if (save-excursion
+ (and c-has-compound-literals
+ (eq (c-backward-token-2 1 nil lim) 0)
+ (eq (char-after) ?\()))
+ (setq braceassignp t)
+ (setq braceassignp nil))))))
(cond
(braceassignp
@@ -11108,9 +11117,14 @@ comment at the start of cc-engine.el for more info."
(and (consp res)
(eq (car res) after-type-id-pos))))))
(cons bufpos (or in-paren inexpr-brace-list)))
- ((eq (char-after) ?\;)
- ;; Brace lists can't contain a semicolon, so we're done.
- ;; (setq containing-sexp nil)
+ ((or (eq (char-after) ?\;)
+ ;; Brace lists can't contain a semicolon, so we're done.
+ (save-excursion
+ (c-backward-syntactic-ws)
+ (eq (char-before) ?}))
+ ;; They also can't contain a bare }, which is probably the end
+ ;; of a function.
+ )
nil)
((and (setq macro-start (point))
(c-forward-to-cpp-define-body)