]> git.eshelyaron.com Git - emacs.git/commitdiff
Analyze C++ method with & or && ref-qualifier as defun, not brace list
authorAlan Mackenzie <acm@muc.de>
Fri, 12 Apr 2019 20:07:03 +0000 (20:07 +0000)
committerAlan Mackenzie <acm@muc.de>
Fri, 12 Apr 2019 20:07:03 +0000 (20:07 +0000)
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

index 1a8c516490695e15c63d76e38cbaf50a9a8ee9fb..fc8c377f2779f92b378d096fca1bab7c777c10c2 100644 (file)
@@ -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)