emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master cc80eeb: Analyze C++ method with & or && ref-qualif


From: Alan Mackenzie
Subject: [Emacs-diffs] master cc80eeb: Analyze C++ method with & or && ref-qualifier as defun, not brace list
Date: Fri, 12 Apr 2019 16:09:31 -0400 (EDT)

branch: master
commit cc80eeb4a43d2079963de3d181002a6a6b56560d
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>

    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.
---
 lisp/progmodes/cc-engine.el | 38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 1a8c516..fc8c377 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]