]> git.eshelyaron.com Git - emacs.git/commitdiff
CC Mode: Fix syntactic context of BOD sometimes being 'topmost-intro-cont
authorAlan Mackenzie <acm@muc.de>
Mon, 27 Aug 2018 20:37:49 +0000 (20:37 +0000)
committerAlan Mackenzie <acm@muc.de>
Mon, 27 Aug 2018 20:37:49 +0000 (20:37 +0000)
This happened when the type of the previous function was a struct, etc.,
declaration.

* lisp/progmodes/cc-mode (c-guess-basic-syntax CASE 5N): Check here (for
'topmost-intro-cont) that the first opening brace after BOD is the opening
brace preceding the starting point.

lisp/progmodes/cc-engine.el

index d1eb3c3d06f9e620a53bce6343161e8c6676e35c..278ade0560cfc066e5e58b4940beb0d910a7f321 100644 (file)
@@ -12280,7 +12280,18 @@ comment at the start of cc-engine.el for more info."
                         ;; The '}' is unbalanced.
                         nil
                       (c-end-of-decl-1)
-                      (>= (point) indent-point))))))
+                      (>= (point) indent-point))))
+                ;; Check that we only have one brace block here, i.e. that we
+                ;; don't have something like a function with a struct
+                ;; declaration as its type.
+                (save-excursion
+                  (or (not (and state-cache (consp (car state-cache))))
+                      ;; The above probably can't happen.
+                      (progn
+                        (goto-char placeholder)
+                        (and (c-syntactic-re-search-forward
+                              "{" indent-point t)
+                             (eq (1- (point)) (caar state-cache))))))))
          (goto-char placeholder)
          (c-add-stmt-syntax 'topmost-intro-cont nil nil
                             containing-sexp paren-state))